首頁  >  問答  >  主體

python - distutils.core和setuptools有什么区别

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

from distutils.core import setup

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

from setuptools import setup, find_packages

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

阿神阿神2741 天前1286

全部回覆(1)我來回復

  • 巴扎黑

    巴扎黑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,為避免不必要的麻煩,當然要用標準模組了。 distutilsPython标准模块,setuptools是第三方模块。而Pycharm不知道你是否安装了setuptools 然後我們看一下

    中有這麼一句:

    setup = distutils.core.setup
    setuptools.setup到底是个什么东西,在setuptools/__init__.py就是這樣。

    回覆
    0
  • 取消回覆