0

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.

BioGeek
  • 21,897
  • 23
  • 83
  • 145
  • In what way does it not work? – Jon Nordby Nov 02 '20 at 08:46
  • You are missing a dollar sign in front of {PASSWORD} – Jon Nordby Nov 02 '20 at 08:46
  • @jonnor: fixed the missing dollar sign. See edit for explanation about how it doesn't work. – BioGeek Nov 02 '20 at 09:00
  • What is the command line that make is invoking? In the example you show you are not prefixing the line with `@` yet in the output you show, the command line isn't printed. So, it's pretty clear that the makefile rule you've shown us is not the same as the makefile rule that's actually in your makefile. These differences can be crucial: we can't debug what you don't show. Remove the `@` from the command line in your recipe and look at what make prints as the command it runs. – MadScientist Nov 02 '20 at 14:23

0 Answers0