用pycharm自动生成的setup文件,使用的是distutils.core里的setup
from distutils.core import setup
但我看很多人写的setup,用的是setuptools
from setuptools import setup, find_packages
这个distutils和setuptools分别是什么背景,怎么同样功能出现两个包呢?
巴扎黑2017-04-18 09:29:25
學會看官方文檔,distutils
的介紹(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 may be either 100%-pure Python, or may be extension moduls extension includes includes includes extension collher includes includes exten。 in both Python and C.
也就是說,整個distutils
包就是负责建立Python
套件就是負責建立Python
擴充模組的安裝器用的。
然後是文檔的第二段:
的優點,這裡就不貼出來了。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 en Packaging Authority. In particative, setuptools is an en Packaging Authority. In particative, setuptools is an enen Packaging Authority. In partic that:
看見了吧,大部分
Python
用户会使用更先进的setuptools
模块,然后文档下面列了几点setuptools
那為什麼Pycharm
會用
setuptools
更強大麼?
Pycharm
会用distutils
呢?不是说setuptools
原因很簡單:
是Python
標準模組,setuptools
是第三方模組。而Pycharm
不知道你是否安裝了setuptools
,為避免不必要的麻煩,當然要用標準模組了。 distutils
是Python
标准模块,setuptools
是第三方模块。而Pycharm
不知道你是否安装了setuptools
然後我們看一下
setup = distutils.core.setup
setuptools.setup
到底是个什么东西,在setuptools/__init__.py
就是這樣。