[FR] Environment variables substitution for dynamic dependencies
What's the problem this feature will solve?
Setuptools supports dynamically specifying dependencies through pyproject.toml using the following syntax:
[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
The requirements.txt format, as described in the pip documentation, includes a proposal for environment variable substitution. However, this functionality is not currently implemented in setuptools.
Describe the solution you'd like
Introduce support in setuptools for substituting environment variables when parsing dependencies from a requirements.txt file. This would enable use cases like the following:
-
Define a private dependency in
requirements.txt:mypackage@https://${PAT}@<pypi-feed>/<path> -
Specify dynamic dependencies in
pyproject.toml:[project] # Other project metadata dynamic = ["dependencies"] [tool.setuptools.dynamic] dependencies = { file = ["requirements.txt"] } -
Set the necessary environment variables before installation:
export PAT=... export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring # To avoid interactive prompts -
Run the installation:
pip install .
This feature would be especially beneficial for non-interactive sessions, such as CI/CD pipelines.
Alternative Solutions
No response
Additional context
No response
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct
Any advance on this? This feature is desperately needed in many situations.