10

I am trying to deploy a Django app to Heroku where one of the required packages lives on https://testpypi.python.org/pypi and of course Django is on the main PyPI server.

The requirements.txt file looks like so:

Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4

running pip install -r requirements.txt fails with the following error:

Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 1))
Cleaning up...
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 1))

So it looks like pip is trying to find Django on testpypi

So I tried this:

-i https://pypi.python.org/pypi/
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4

It results in the same error.

If I place just one (doen't matter witch one) of packages in the requirements file pip is able to find the package and install it.

Question: What is the correct syntax for specifying multiple different index-url arguments within a single file that can be read by the command pip install -r file

I don't think it matters but python is version 3.4.0 and pip is version pip 1.5.2.

I have updated pip to version 6.0.8, error now reads as:

Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 2))
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 2))
Selcuk
  • 57,004
  • 12
  • 102
  • 110
robbmj
  • 16,085
  • 8
  • 38
  • 63

1 Answers1

18

By definition, any private index definition will apply to every package

https://devcenter.heroku.com/articles/python-pip#private-indexes

All dependencies specified in that requirements file will resolve against that index.

As a workaround, you can create multiple requirements files and cascade them:

https://devcenter.heroku.com/articles/python-pip#cascading-requirements-files

If you would like to utilize multiple requirements files in your codebase, you can include the contents of another requirements file with pip:

-r ./path/to/prod-requirements.txt

Update: It turns out that the correct method of dealing with private indexes is to use --extra-index-url switch. From the documentation of pip:

Note that using --index-url removes the use of PyPI, while using --extra-index-url will add additional indexes.

So, putting the line

--extra-index-url https://test.pypi.org/simple/

on top of your requirements.txt should be enough. No need to cascade at all!

Selcuk
  • 57,004
  • 12
  • 102
  • 110