python - distutils.core和setuptools有什么区别
阿神
阿神 2017-04-18 09:27:25
0
1
1280

用pycharm自动生成的setup文件,使用的是distutils.core里的setup

from distutils.core import setup

但我看很多人写的setup,用的是setuptools

from setuptools import setup, find_packages

这个distutils和setuptools分别是什么背景,怎么同样功能出现两个包呢?

阿神
阿神

闭关修行中......

reply all(1)
巴扎黑

Learn to read official documents, distutilsIntroduction (distutils - python2):

The distutils package provides support for building and installing additional modules into a Python installation. The new modules may be either 100%-pure Python, or may be extension modules written in C, or may be collections of Python packages which include modules coded in both Python and C.

In other words, the entire distutils包就是负责建立Python package is responsible for creating the installer for the Python extension module.
Then the second paragraph of the document:

Most Python users will not want to use this module directly, but instead use the cross-version tools maintained by the Python Packaging Authority. In particular, setuptools is an enhanced alternative to distutils that provides:

You see, most of Python用户会使用更先进的setuptools模块,然后文档下面列了几点setuptools’s advantages are not posted here.

So why does Pycharm use Pycharm会用distutils呢?不是说setuptools? Isn’t it said that setuptools is more powerful?

The reason is simple:
distutilsPython标准模块,setuptools是第三方模块。而Pycharm不知道你是否安装了setuptools is a Python standard module, and setuptools is a third-party module. And Pycharm does not know whether you have installed setuptools. To avoid unnecessary trouble, of course you must use standard modules.

Then let’s take a look at this sentence in setuptools.setup到底是个什么东西,在setuptools/__init__.py:

setup = distutils.core.setup

That’s it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!