Tool recommendations¶
If you’re familiar with Python packaging and installation, and just want to know what tools are currently recommended, then here it is.
Application dependency management¶
Use pip in a secure manner to install a Python application and its dependencies during deployment.
Use virtualenv or venv to isolate application-specific dependencies from a shared Python installation. 4
Use pip-tools, Pipenv, or poetry to generate the fully-specified application-specific dependencies, when developing Python applications.
Installation tool recommendations¶
Use pip to install Python packages from PyPI. 1 2 Depending on how pip is installed, you may need to also install wheel to get the benefit of wheel caching. 3
Use virtualenv or venv to isolate project-specific dependencies from a shared Python installation. 4
If you’re looking for management of fully integrated cross-platform software stacks, consider:
Packaging tool recommendations¶
Use setuptools to define projects. 5 6
Use build to create Source Distributions and wheels.
If you have binary extensions and want to distribute wheels for multiple platforms, use cibuildwheel as part of your CI setup to build distributable wheels.
Publishing platform migration¶
The original Python Package Index implementation (previously hosted at pypi.python.org) has been phased out in favour of an updated implementation hosted at pypi.org.
See 迁移到 PyPI.org for more information on the status of the migration, and what settings to change in your clients.
- 1
There are some cases where you might choose to use
easy_install
(from setuptools), e.g. if you need to install from Eggs (which pip doesn’t support). For a detailed breakdown, see pip 与 easy_install.- 2
The acceptance of PEP 453 means that pip will be available by default in most installations of Python 3.4 or later. See the rationale section from PEP 453 as for why pip was chosen.
- 3
get-pip.py and virtualenv install wheel, whereas ensurepip and venv do not currently. Also, the common “python-pip” package that’s found in various linux distros, does not depend on “python-wheel” currently.
- 4(1,2)
Beginning with Python 3.4,
venv
will create virtualenv environments withpip
installed, thereby making it an equal alternative to virtualenv. However, using virtualenv will still be recommended for users that need cross-version consistency.- 5
Although you can use pure
distutils
for many projects, it does not support defining dependencies on other projects and is missing several convenience utilities for automatically populating distribution metadata correctly that are provided bysetuptools
. Being outside the standard library,setuptools
also offers a more consistent feature set across different versions of Python, and (unlikedistutils
), recent versions ofsetuptools
support all of the modern metadata fields described in Core metadata specifications.Even for projects that do choose to use
distutils
, when pip installs such projects directly from source (rather than installing from a prebuilt wheel file), it will actually build your project using setuptools instead.- 6
distribute (a fork of setuptools) was merged back into setuptools in June 2013, thereby making setuptools the default choice for packaging.