Description
Quoting from https://gregoryszorc.com/blog/2023/10/30/my-user-experience-porting-off-setup.py/:
Outdated Tool Recommendations from the PyPA
Finally I find Tool recommendations in the PyPA User Guide. Under Packaging tool recommendations it says:
- Use setuptools to define projects.
- 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.
- Use twine for uploading distributions to PyPI.
Finally, some canonical documentation from the PyPA that comes out and suggests what to use!
But my relief immediately turns to questioning whether this tooling recommendations documentation is up to date:
- If setuptools is recommended, why does the Packaging Python Projects tutorial use Hatch?
- How exactly should I be using setuptools to define projects? Is this referring to setuptools as a [build-system] backend? The existence of define seemingly implies using setup.py or setup.cfg to define metadata. But I thought these distutils/setuptools specific mechanisms were deprecated in favor of the more generic pyproject.toml?
- Why aren't other tools like Hatch, pip, poetry, flit, and pdm mentioned on this page? Where's the guidance on when to use these alternative tools?
- There are footnotes referencing distutils as if it is still a modern practice. No mention that it was removed from the standard library in Python 3.12.
- But the build tool is referenced and that tool is relatively new. So the docs have to be somewhat up-to-date, right?
These are all valid concerns.
I'm willing to do the work of updating that page, but I think this is a potentially very delicate/controversial topic, so I figured I'd open an issue to agree on a plan first, so as not to mix this discussion with PR review details.
Some thoughts by tool category:
- I think we can agree that pip should be recommended. But this could/should also mention pipx for the specific case of CLI tools. I don't think pipx has much competition right now (though it may have in the future).
- The recommendation of virtualenv/venv is fine. But we could mention that there many (a great many) tools out there to manage environments more automatically (virtualenvwrapper, Poetry/PDM/Hatch, etc.)
- The recommendation of pip-tools, Pipenv or poetry for lock files could be expanded to include PDM.
- I think we should drop buildout and Hashdist, both of these are dead judging from Git commit history, especially Hashdist.
- I do not think the PyPA should officially recommend setuptools as a build backend. After all, the explicit purpose of PEP 517 was to allow other backends. Here, I think we should simply list the different alternatives without making anything that would look like an official choice, since there is no consensus on such a choice. The backends could be listed in the same order as the tabs in the "Packaging projects" tutorial.
- The cibuildwheel recommendation is fine. I don't think there are any serious alternatives.
- I'm not sure about recommending
build
andtwine
. Certainly, they're better thanpython setup.py bdist_wheel
andpython setup.py upload
, but the equivalent Hatch/Poetry/PDM commands are fine too.
By and large, I think we should make less recommendations on that page, be more objective, and especially avoid recommending a given tool when there is no consensus among PyPA members that this should be the blessed tool, since the officialness of the page makes users believe that a consensus exists. For better or worse, there is more good advice to be given on what not to use — e.g., this could be a good page to remind things like "don't use python setup.py upload
", "don't use distutils", and "whichever backend you choose, declare it in the [build-system]
table".
One other thing I'm not sure about is the status of Pipenv (how well-maintained is it and are many people using it after all the controversy that there was around it?).