5

I am running a local pypi server. I can install packages from this server by either specifying it with the -i option of the pip command or by setting the PIP_INDEX_URL environment variable. When I install a package that has prerequisites, setup.py has historically honored the PIP_INDEX_URL environment variable, pulling the additional packages from my local server.

However, on a couple of systems that have been recently installed, it is behaving differently. Running, for instance, python setup.py develop fails because it tries to install prerequisites packages from pypi.python.org.

I have updated all of the related python packages (python, distribute, virtualenv, pip, etc...) on all the systems I'm testing on and continue to see this discrepancy. On my "original" system, setup.py downloads prerequisites from the pypi server specified in my PIP_INDEX_URL environment variable. On the newer systems, I can't seem to make it honor this variable.

What am I missing?

mmoya
  • 1,901
  • 1
  • 21
  • 30
zenzic
  • 1,517
  • 2
  • 16
  • 25
  • It looks like this was partially answered by http://stackoverflow.com/questions/3472430/how-can-i-make-setuptools-install-a-package-thats-not-on-pypi. It doesn't explain why the environment variable is being inconsistently honored, but it does tell me how to solve my problem by specifying dependency_links. – zenzic Feb 10 '14 at 21:05
  • 1
    And I finally found the culprit. On the old server, I had a `~/.pydistutils` file which directed easy_install to use my pypi server. Once I created this file on the new servers, my deployments worked again. It still doesn't use the PIP_INDEX_URL variable, but this gives me a way around it. – zenzic Mar 07 '14 at 18:11

2 Answers2

3

Create setup.cfg in the same folder as your setup.py with following content:

[easy_install]
allow_hosts = *.myintranet.example.com

From: http://pythonhosted.org/setuptools/easy_install.html#restricting-downloads-with-allow-hosts

You can use the --allow-hosts (-H) option to restrict what domains EasyInstall will look for links and downloads on.

--allow-hosts=None prevents downloading altogether.


iljau
  • 2,151
  • 3
  • 22
  • 45
  • Thanks for the info. I'll give that a try. I'm still baffled as to why I see different behavior between systems running the same software, though. – zenzic Feb 11 '14 at 16:27
  • @zenzic if you use `python setup.py develop`, then [`distutils`](http://docs.python.org/2/library/distutils.html) takes care of installation. For backgroud information there's an article that summarizes the (sorry) state of python packaging: http://lucumr.pocoo.org/2012/6/22/hate-hate-hate-everywhere/ – iljau Feb 11 '14 at 16:45
  • that is what I expected but not seeing. I am still beating my head against this problem and not finding an acceptable solution. What it comes down to is that `python setup.py develop` uses easy_install to install dependencies specified in setup.py (`install_requires`). easy_install ignores the PIP_INDEX_URL environment variable. I don't want to hardcode an index server in setup.py or setup.cfg, I want it to use the one specified in the environment. Is there some better way to accomplish this? – zenzic Mar 06 '14 at 16:28
3

I ran into the same issue. Fundamentally, setup.py is using setuptools which leverages easy_install, not pip. Thus, it ignores any pip-related environment variables you set.

Rather than use python setup.py develop you can run pip (from the top of the package) pip install -e . to produce the same effect.

stkent
  • 19,772
  • 14
  • 85
  • 111
sconsin
  • 31
  • 1