Description
Description
Let's say we have a project called A
in a Github repository from an organization, that has a requirements.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 own requirements.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 project B
everything works fine. The C
project is installed as a dependency of B
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 the B
dependency, injecting the ${PAT_TOKEN}
from env vars, but now B
requires to install C
, 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
- Create a private repository
A
in GitHub inside an organizationO
, and commit some random code that imports packageB
. - Create a private repository
B
in GitHub inside an organizationO
, and commit some random code that imports packageC
. - Create a private repository
C
in GitHub inside an organizationO
, and commit some random code. - Create a
requirements.txt
file for projectA
and add the following line:
B @ git+https://${PAT_TOKEN}@github.com/O/[email protected]
- Create a
requirements.txt
file for projectB
and add the following line:
C @ git+https://${PAT_TOKEN}@github.com/O/[email protected]
- In your account settings, create a personal access token that can be used for all the respositories within the organization.
- Run
pip install -r requirements.txt
forA
project.
Output
...
Collecting B@ git+https://****@github.com/O/B (from -r requirements.txt (line 1))
Cloning https://****@github.com/O/B (to revision v0.1.0) to /tmp/pip-install-l1b_8yth/B_afff0d9438154e0bbd86cc84bd9a6408
Running command git clone --filter=blob:none --quiet 'https://****@github.com/O/B' /tmp/pip-install-l1b_8yth/B_afff0d9438154e0bbd86cc84bd9a6408
Resolved https://****@github.com/O/B to commit 04060492b1907ca817366f20be6a87a32680bf04
Installing build dependencies: started
...
Collecting C@ git+https://****@github.com/O/[email protected] (from B@ git+https://***@github.com/O/[email protected]>-r requirements.txt (line 1))
Cloning https://****@github.com/O/C (to revision v0.1.0) to /tmp/pip-install-l1b_8yth/C_66e1729f35a1430fa58d589084f2aacd
Running command git clone --filter=blob:none --quiet 'https://****@github.com/O/C' /tmp/pip-install-l1b_8yth/C_66e1729f35a1430fa58d589084f2aacd
fatal: could not read Password for 'https://${PAT_TOKEN}@github.com': No such device or address
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet 'https://****@github.com/O/C' /tmp/pip-install-l1b_8yth/C_66e1729f35a1430fa58d589084f2aacd did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
Code of Conduct
- I agree to follow the PSF Code of Conduct.