Closed as not planned
Description
It's very typical to see a code block like this in setup.py
:
with open("requirements.txt", encoding="utf-8") as f:
# Make sure we strip all comments and options (e.g "--extra-index-url")
# that arise from a modified pip.conf file that configure global options
requires = []
for line in f:
req = line.split("#", 1)[0].strip()
if req and not req.startswith("--"):
requires.append(req)
setup(
...
install_requires=requires,
However, as pointed out by the setuptools maintainers, requirements.txt
files were always meant for pip, not for build backends (hence the stripping of comments and --<options>
).
setuptools ships beta support for consuming them in pyproject.toml
:
dynamic = ["dependencies"]
...
[tool.setuptools.dynamic]
dependencies = {file = "requirements.txt"}
(see documentation)
But it breaks workflow tools that rely on adding deps statically to [project.dependencies]
, for example poetry, pdm, rye, uv.
Would you be open to adding an option that helps users migrate from having their deps in requirements.txt
to having them in [project.dependencies]
?
Metadata
Assignees
Labels
No labels