How to specify install order for python pip?

2019-01-13 20:09发布

I'm working with fabric(0.9.4)+pip(0.8.2) and I need to install some python modules for multiple servers. All servers have old version of setuptools (0.6c8) which needs to be upgraded for pymongo module. Pymongo requires setuptools>=0.6c9.

My problem is that pip starts installation with pymongo instead of setuptools which causes pip to stop. Shuffling module order in requirements file doesn't seem to help.

requirements.txt:

setuptools>=0.6c9
pymongo==1.9
simplejson==2.1.3

Is there a way to specify install order for pip as it doesn't seem to do it properly by itself?

This can be resolved with two separate requirements files but it would be nice if I didn't need to maintain multiple requirements files now or in the future.

Problem persists with pip 0.8.3.

9条回答
ゆ 、 Hurt°
2楼-- · 2019-01-13 20:38

If you have comments in your requirements file you'll want to use:

grep -v "^#" requirements.txt | xargs pip install
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-13 20:40

Sorry, my first answer was wrong, because I had setuptools>=0.6c9.

It seems it is not possible because pymongo's setup.py needs setuptools>=0.6c9, but pip has only downloaded setuptools>=0.6c9, and not installed yet.

Someone discussed about it in the issue I pointed before.

I have my own created an issue some weeks ago about it: Do not run egg_info to each package in requirements list before installing the previous packages.

Sorry for the noisy.


First answer:

Upgrade your pip to 0.8.3 version, it has a bugfix to installation order.

Now if you upgrade everything works :-)

Check the news here: http://www.pip-installer.org/en/0.8.3/news.html

查看更多
Deceive 欺骗
4楼-- · 2019-01-13 20:44

I ended up running pip inside virtualenv instead of using "pip -E" because with -E pip could still see servers site-packages and that obviously messed up some of the installs.

I also had trouble with servers without virtualenvs. Even if I installed setuptools with separate pip command pymongo would refuse to be installed.

I resolved this by installing setuptools separately with easy_install as this seems to be problem between pip and setuptools.

snippets from fabfile.py:

env.activate = "source %s/bin/activate" % virtualenv_path

_virtualenv("easy_install -U setuptools")
_virtualenv("pip install -r requirements.txt")

def _virtualenv(command)
    if env.virtualenv:
        sudo(env.activate + "&&" + command)
    else:
        sudo(command)

I had these problems with pip 0.8.3 and 0.8.2.

查看更多
登录 后发表回答