I have a private PyPI repository. Is there any way to store credentials in pip.conf
similar to .pypirc
?
What I mean. Currently in .py
Given issue 4789 is still open, you can utilize the following approach in your requirements.txt:
--extra-index-url=https://${PYPI_USERNAME}:${PYPI_PASSWORD}@my.privatepypi.com
private-package==1.2.3
...
If you try to run pip install requirements.txt
with those environment variables set, you will find that pip still asks for credentials. This is because pip does not interpolate the expression ${PYPI_USERNAME}
as one would expect, but rather url encodes it. Your username and password in this example is expressed as https://%24%7BPYPI_USERNAME%7D:%24%7BPYPI_PASSWORD%7D@my.privatepypi.com
The work around here, and I admit there should be a better approach, but we can run pip as a script:
python3 -m pip install -r requirements.txt
From man:
-m module-name
Searches sys.path for the named module and runs the corresponding .py file as a script.