python – distribution

Refs:

  1. https://packaging.python.org/tutorials/distributing-packages/#packaging-your-project
  2. https://blog.zengrong.net/post/2169.html
  3. http://pyzh.readthedocs.io/en/latest/python-setup-dot-py-vs-requirements-dot-txt.html

Distribution

A versioned archive file that contains Python packages, modules, and other resource files that are used to distribute a Release. The archive file is what an end-user will download from the internet and install.

  • Distribution Package: 其实就是 python 文件的压缩包,比如 requests,解压之后里面就是 requests 的源代码。
  • Built Distribution: 前者叫做构建版本,提供 files 和 metadata,但是 sdist (source distribution) 不算,因为它需要构建之后才生成 BD.
  • Binary Distribution: 属于特殊的 Built Distribution,即包含了编译好的文件。

Egg & Wheel

Wheels are a pre-built distribution format that provides faster installation compared to Source Distributions (sdist), especially when a project contains compiled extensions.

Pip can install from either Source Distributions (sdist) or Wheels, but if both are present on PyPI, pip will prefer a compatible wheel.

If pip does not find a wheel to install, it will locally build a wheel and cache it for future installs, instead of rebuilding the source distribution in the future.

  • Egg 是 setuptools 引进的一种用于 Built Distribution 的格式。
  • Wheel 同样是一种 BD 的格式,并且由 pip 提供支持,并用来替代 Egg.