Repository navigation
Is it safe to pin setuptools/distribute/pip in requirements.txt? #6459
Description
Activity
The pinning issue aside, why is a Markdown module depending on setuptools in the first place? :(
Python-Markdown requires
setuptools>=36because it wants to setmarkdown.__version__ = pkg_resources.extern.packaging.version.Version(...).pytest requires
setuptools>=40.0because it wants to use py_modules in setup.cfg.I don't know that either of those reasons was necessary, but are they a problem? It seems better to tell package authors "go ahead and depend on features of a minimum setuptools if you want to," rather than "be sure to support all versions of setuptools in use" -- otherwise new features of setuptools will take many years to be usable.
But if package authors are allowed to set minimum setuptools versions, then it also seems better (safer?) to pin that version in a requirements.txt file rather than letting each deployment end up with a different version.
I’d say there are better ways to do what the packages want to do. Maybe conceptually there is a case pip should handle itself (and setuptools) more gracefully in hash mode, or maybe pip-tools should allow pip/setuptools to be locked, that’s up for discussion. These particular usages do no make a strong case, however, IMHO.
The pytest usecase is pretty reasonable, isn't it? setuptools introduced an updated config file format and they want to use it -- that seems OK.
I poked around a bit more via a Google search on github. Some other popular packages setting minimum setuptools versions: kubernetes-client requires setuptools>=21.0.0; ipython requires setuptools>=18.5
I'm not sure it really matters how good the reasons are, does it? It's valid syntax; it's harmless, as far as anyone knows; it presumably solved a problem when introduced; and it's used in popular packages. Trying to convince package authors to never use it seems like a harder approach than tweaking pip-tools to handle it -- unless for some reason that wouldn't work.
I believe
setup_requiresor the PEP 518 build requirement is better for describing their intention 🙂But regardless of whether Pytest can do better, I believe setuptools should be able to be pinned, since it does have a Python API (
pkg_resources) that is useful for certain kind of projects. Whether pip-tools should allow pinning it, or pip should allow skipping it in hash mode, that needs to be discussed.- addedS: needs triageIssues/PRs that need to be triagedIssues/PRs that need to be triaged
on Jun 22, 2019 - addedproject: vendored dependencyRelated to a vendored dependencyRelated to a vendored dependencystate: needs discussionThis needs some more discussionThis needs some more discussiontype: questionUser questionUser question
on Jul 21, 2019 - ghost removedS: needs triageIssues/PRs that need to be triagedIssues/PRs that need to be triaged
on Jul 21, 2019 - added a commit that references this issue
on Mar 12, 2021 - added a commit that references this issue
on Jul 4, 2023 - added a commit that references this issue
on Jul 11, 2023 - added a commit that references this issue
on Jan 19, 2024 - added 2 commits that reference this issue
on Jan 9, 2025
pip 19.1Python 3.5.3macOS 10.14.4As documented in this issue over at pip-tools, if you install packages like
pytestorMarkdownwith--require-hashesyou have to pin a specific version ofsetuptoolsas well, because it's included in their dependencies:The pip-tools project does not pin setuptools without the scary-sounding
--allow-unsafeflag, because "it may cause conflicts with pip itself". But the maintainers don't currently have a failing test case or know what the conflict would be. It also appears that setuptools was vendored by pip at some point, which might have changed the equation.Can anyone on the pip side clarify under what circumstances it might be safe or unsafe to pin setuptools, and thus what the correct behavior would be for
pip-compile --generate-hashesin the linked bug? To promote the use of --require-hashes, it would be great to either narrow pip-compile's definition of "unsafe", or provide clearer instructions about how to handle the unsafety when needed.The other two packages on pip-compile's "unsafe" list are
distributeandpipitself, so I guess the same question applies to those as well -- are there any risks as far aspipis concerned to pinning them if necessary to satisfy--require-hashes?Thanks!