28.1. distutils — 构建和安装 Python 模块

The distutils 包在 Python 安装中提供构建和安装额外模块的支持。新模块可能是 100% 纯 Python,也可能是以 C 编写的扩展模块,或可能是 Python 包的集合 (包括以 Python 和 C 编码的模块)。

大多数 Python 用户 not 想直接使用此模块,而是使用由 PPA (Python 打包管理局) 所维护的跨版本工具。尤其, setuptools 增强替代 distutils 提供:

  • 支持声明工程依赖
  • additional mechanisms for configuring which files to include in source releases (including plugins for integration with version control systems)
  • the ability to declare project “entry points”, which can be used as the basis for application plugin systems
  • the ability to automatically generate Windows command line executables at installation time rather than needing to prebuild them
  • 跨所有支持 Python 版本行为一致

推荐 pip 安装程序运行所有 setup.py 脚本采用 setuptools ,即使脚本本身只导入 distutils 。参考 Python 打包用户指南 了解更多信息。

为让打包工具作者和用户更深入理解当前打包的细节及分发系统,基于传统 distutils 的用户文档编制和 API 参考仍然可用:

上一话题

28. 软件打包和分发

下一话题

28.2. ensurepip — 自引导 pip 安装程序

本页