6

As the title says, does pip support http authentication, like easy_install does?

If not, are there any (better) alternatives to running a private package repository? I see pip can access source repositories (git,svn etc.), but can version requirements be used with this?

4 Answers4

6

For people still searching for an answer you can use the following syntax:

pip install -r https://user:pass@domain.com/path/requirements.txt

An also if you require to validate their certificate use:

pip install --cert host.pem -r https://user:pass@domain.com/path/requirements.txt

This is working on:

$ pip --version
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages (python 2.7)

To upgrade your pip do:

pip install --upgrade pip
Havok
  • 5,776
  • 1
  • 35
  • 44
  • There's no way to do this without using plaintext passwords? – cowlinator Feb 05 '20 at 20:12
  • I just found this: https://github.com/pypa/pip/pull/5952 . It appears that you can use keyring with pip, but I can't find any usage documentation. It also appears that pip supports `.netrc` files in `~` and `.`, but again, no usage documentation. – cowlinator Feb 07 '20 at 00:22
3

pip uses urllib2.urlopen() to fetch files. urllib2.urlopen() supports HTTP authentication, but pip doesn't appear to install the HTTPBasicAuthHandler when it builds its opener. Adding such support would be trivial; you could either parse the URL for user:password or accept the same information as command line parameters. feedparser supports both methods by subclassing urllib2.HTTPDigestAuthHandler.

lt_kije
  • 425
  • 2
  • 4
2

Currently simply pip does not support authentication.

But the main author of pip thinks that feature is desirable so probably it will appear in the medium future. There is also an item in the PIP trac containing a patch to enable http auth.

max
  • 29,122
  • 12
  • 52
  • 79
2

FYI, it's currently being worked on in the http_auth_index branch which will allow the use of basic auth for custom indexes.

jezdez
  • 1,499
  • 2
  • 8
  • 9