-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip doesn't resolve ENV vars in the requirements.txt file of the dependencies of a given dependency (recursive in depth) #13151
Comments
As you can see from the error:
For But when you pass a source tree, like a file path or a git link, pip invokes the defined build backend (setuptools, hatchling, poetry.core, flit, etc.) to build the package, it then receives that packages dependency metadata from the build backend, pip does not try to read any You've not provided a reproducible example of how you've set these projects up, but if you have a |
Ok. I thought that the behavior was:
I am using
Maybe the problem comes from the dynamic dependencies injection of Thanks. |
Correct. The specification
is interpreted by setuptools. The requirements file format is not standardised, so how setuptools interprets that line is up to setuptools, and it appears that they don't expand environment variables when evaluating the You would have to ask the setuptools project who to achieve what you're trying to do - pip isn't involved in building projects apart from invoking the build backend (setuptools in this case). |
Description
Let's say we have a project called
A
in a Github repository from an organization, that has arequirements.txt
file with the following dependencies:B @ git+https://${PAT_TOKEN}@github.com/MY_ORGANIZATION/[email protected]
Then we have the project
B
also in a Github repository from the same organization, with his ownrequirements.txt
file. For example:C @ git+https://${PAT_TOKEN}@github.com/MY_ORGANIZATION/[email protected]
As said, all projects belong to the same Github organization (also
C
), so we can create a Personal Access Token (PAT) that can be used for authenticating in all projects. We export the PAT_TOKEN and set it as an environment variable in a terminal.If we do
pip install -r requirements.txt
for projectB
everything works fine. TheC
project is installed as a dependency ofB
and the${PAT_TOKEN}
is correctly read from the environment variables, resolving the url, doing the checkout, etc.However, if we do the same for project
A
it fails. Initially, it correctly resolves theB
dependency, injecting the${PAT_TOKEN}
from env vars, but nowB
requires to installC
, and in that case the${PAT_TOKEN}
is not replaced by the env variable, but passed literally to the checkout, then failing.Expected behavior
The value of ${PAT_TOKEN} environment variable must be passed recursively to all dependencies and dependencies of dependencies.
pip version
24.3.1
Python version
3.11
OS
linux
How to Reproduce
A
in GitHub inside an organizationO
, and commit some random code that imports packageB
.B
in GitHub inside an organizationO
, and commit some random code that imports packageC
.C
in GitHub inside an organizationO
, and commit some random code.requirements.txt
file for projectA
and add the following line:B @ git+https://${PAT_TOKEN}@github.com/O/[email protected]
requirements.txt
file for projectB
and add the following line:C @ git+https://${PAT_TOKEN}@github.com/O/[email protected]
pip install -r requirements.txt
forA
project.Output
Code of Conduct
The text was updated successfully, but these errors were encountered: