I've seen on Python Docs that distutils is "legacy" since Python 3.4. What is now the recommended (or standard) way to distribute packages and/or modules. Thanks
2 Answers 2
Well, the documentation for the distutils module says it all:
The
distutilspackage 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 modules written in C, or may be collections of Python packages which include modules coded in both Python and C.Most Python users will not want to use this module directly, but instead use the cross-version tools maintained by the Python Packaging Authority. Refer to the Python Packaging User Guide for more information.
For the benefits of packaging tool authors and users seeking a deeper understanding of the details of the current packaging and distribution system, the legacy distutils based user documentation and API reference remain available:
In particular inside the linked user guide they state:
- Use
setuptoolsto define projects and create Source Distributions. [5] [6]- Use the
bdist_wheelsetuptoolsextension available from the wheel project to create wheels. This is especially beneficial, if your project contains binary extensions. [7]- Use
twinefor uploading distributions to PyPI.
And later on:
distributewas a fork ofsetuptoolsthat was merged back into setuptools (in v0.7), thereby making setuptools the primary choice for Python packaging.
In other words:
distutilsis still the standard way. Only, it's more low level than what most people want. It's the foundantion on top of which the other tools are built, so it is not "legacy". In fact there is no mention of deprecation in the docs.setuptoolsis the preferred way to distribute a package.
Comments
According to the Python Packaging User Guide it is recommended to use setuptools and then twine to create PyPi packages.