I have a Makefile with an install
command which installs Python packages from a private Pypi repository.
install:
python3 -m pip install --extra-index-url https://${USERNAME}:${PASSWORD}@company.com/artifactory/api/pypi/simple -r requirements.txt
For now I have my credentials hardcoded and that works. But I can't check my code in into version control like that. However, I don't want to enter my username and password every time I run this command. Preferably I would like to have the Makefile read those values from my environment variables. Is this possible?
I have tried different variations of setting the username like
export USERNAME=`id -u -n`
and reading the password like:
PASSWORD ?= $(shell stty -echo; read -p "Password: " pwd; stty echo; echo $$pwd)
but I can't get it to work.
edit
In what way does it not work?
When I for example do
$ source .env
$ echo $USERNAME
biogeek # OK, as expected
$ make install
Looking in indexes: https://pypi.org/simple, https://:****@company.com/artifactory/api/pypi/simple, https://%24%7USER%7D:****@company.com/artifactory/api/pypi/simple,
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI (from -r docker/environments/tf2/requirements.txt (line 3))
Cloning https://github.com/philferriere/cocoapi.git to /tmp/pip-req-build-bngt4yfh
User for company.com:
Notice that ${USER}
is replaced with %24%7USER%7D
instead of my username. (Might be related to this issue). It also can't login to pypi so it shows the password prompt that I ant to avoid.