Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pip with two --extra-index-url arguments that both point to the same domain

Tags:

python

pip

We use our own python package index at my office, and we're trying to add a new one. When I try to specify both indices at the same time, I get prompted to log in, but if I use only one at a time I don't.

For example:

$ pip install --user --upgrade \
    --extra-index-url https://<api token>:@packagecloud.io/2rs2ts/oldrepo/pypi/simple \
    --extra-index-url https://<other api token>:@packagecloud.io/2rs2ts/newrepo/pypi/simple \
    mypackage
Collecting mypackage
User for packagecloud.io:

But if I specify just one of either of those --extra-index-url arguments then I download my package just fine.

I'm 99% certain that I am passing the arguments correctly, since it's specified with an append action in the source. So I think the problem is that both of these index URLs are from packagecloud.io... but I could be wrong. Either way, how can I use both of my repos?

like image 430
2rs2ts Avatar asked Aug 22 '16 17:08

2rs2ts


People also ask

What is pip extra Index URL?

Use the extra-index-url option to tell pip where your alternate package index lives. If your package index doesn't support SSL, you can supress warnings by identifying it as a trusted-host . The example below assumes the name of your server is pypi.mydomain.com and you're running on non-standard port 8080.

What is PyPI repository?

The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community. Learn about installing packages. Package authors use PyPI to distribute their software.

Where is pip config?

$HOME/. config/pip/pip.


2 Answers

Apparently this is a bug in pip. The HTTP basic auth information is not stored correctly when specifying multiple --extra-index-urls that point to the same domain. I filed an issue, but in the meantime, there is a workaround. By specifying one of the --extra-index-urls as the --index instead, and adding PyPI as an --extra-index-url, I was able to download my package successfully:

$ pip install --user --upgrade \
    --index https://<api token>:@packagecloud.io/2rs2ts/oldrepo/pypi/simple \
    --extra-index-url https://<other api token>:@packagecloud.io/2rs2ts/newrepo/pypi/simple \
    --extra-index-url https://pypi.python.org/simple \
    mypackage
Collecting mypackage
  Downloading https://packagecloud.io/2rs2ts/newrepo/pypi/packages/mypackage-1.0.0-py2-none-any.whl (52kB)
etc. etc.
like image 148
2rs2ts Avatar answered Oct 05 '22 22:10

2rs2ts


You can also use the environment variable PIP_EXTRA_INDEX_URL. And then you have to use space as delimiter.

export PIP_EXTRA_INDEX_URL="https://user:token@repo-a/ https://user:token@repo-b/"
pip install

I found something about env vars here in the docs. Based on the example about PIP_FIND_LINKS, I tried space and it worked.

like image 21
The Fool Avatar answered Oct 05 '22 23:10

The Fool