Question

I have been trying to work this out for some time, I even tried asking the question here, but did so rather badly. Since then, I've come to understand what is going on a little better. I believe the root of the problem is that when I run python setup.py [install|develop], it attempts to fulfill dependencies (install_requires) using easy_install rather than pip.

That may not sound like a problem, but I run my own pypi server where these dependencies are stored. I can specify that pip use my index server with the PIP_INDEX_URL environment variable. This works fine when deploying with pip install, but while developing, I want the convenience of installing with setup.py develop. From what I can tell, setup.py calls easy_install and it pays no attention to this environment variable, trying to find my packages on pypi.python.org. I know that from the command line, I can specify an index server for easy_install, but see no way to do that when it is being called implicitly from setup.py.

I am further confused by the fact that pip doesn't encounter this problem. When I pip install one of these modules, it runs setup.py for my package, but picks up the dependencies from my index server. Why does setup.py behave differently when run under pip than when I directly invoke it?

Specifying dependency_links in setup.py is not a good answer as I want my environment to determine which pypi server to use (e.g. prod, test, or dev).

My setup doesn't seem that odd to me, so surely others have encountered and resolved this.

Was it helpful?

Solution

Why does setup.py behave differently when run under pip than when I directly invoke it?

PIP_INDEX_URL environment variable is a pip feature.

Your setup.py file uses setuptools which does not know about PIP_INDEX_URL.

I would suggest using:

PIP_INDEX_URL=http://yourpypi/ pip install .

instead of

python setup.py install

OTHER TIPS

You might be interested in pip's "editable install" option, specified with the -e flag:

“Editable” installs are fundamentally “setuptools develop mode” installs.

For local projects, the “SomeProject.egg-info” directory is created relative to the project path. This is one advantage over just using setup.py develop, which creates the “egg-info” directly relative the current working directory.

This doesn't really answer my question as I still don't know how to make setup.py use pip rather than easy_install. However, I did find a solution to my problem. You can force easy_install to use the index server of your choice by specifying it in your ~/.pydistutils file. Something like:

[easy_install]
index_url = http://pypi.my_domain.org/simple
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top