Python虚拟环境--system-site-packages选项--pip行为意外

3
我有许多使用虚拟环境的Python服务。我有时会重建这些环境,并希望节省时间。mkvirtualenv --system-site-packages似乎接近我想要的,但它仍然有我不理解的行为。
我使用的一个包是gevent(beta版本),我直接从GitHub安装:sudo pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent。这是在虚拟环境外完成的,因此它进入系统的site-packages。这很好用,如果我创建一个新的--system-site-packages虚拟环境,它似乎存在,但具有不同的rev和egg指定。
[msherry@hostname:~]$ mkvirtualenv test --system-site-packages
New python executable in test/bin/python2.7
Also creating executable in test/bin/python
Installing setuptools............done.
Installing pip...............done.
[msherry@hostname:~]$ workon test
[msherry@hostname:~]$ pip freeze|grep gevent
-e git://github.com/surfly/gevent.git@15418fc8ff4460069cf42b4b0341969c54455ddd#egg=gevent-dev

至少看起来已经安装了。但是,当我运行 pip install -e git://github.com/surfly/gevent.git@1.0b4#egg=gevent 时,gevent 的(缓慢)安装过程重新开始了——使用 --system-site-packages 看起来我没有获得任何好处。
理想情况下,我希望 pip 能够注意到我正在请求的 gevent 版本已经存在,并且不尝试再次安装它。有没有办法实现我的目标?

1
这个问题被标记为无效并关闭了,但没有任何关于原因的评论。我可以重现这种奇怪的行为。 - jterrace
1个回答

0

在系统范围内安装时,请尝试稍微不同的语法。

sudo pip install git+git://github.com/surfly/gevent.git@1.0b4#egg=gevent

这与您的几乎相同,只是没有-e并包括<vcs>前缀到您的URL。如果没有这个,pip会说

AssertionError: Sorry, 'git://github.com/surfly/gevent.git' is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyApp

我还注意到了与您一样的事情,当通过pip以“可编辑”模式安装软件包时:我得到了提交哈希版本,就像您使用pip freeze | grep gevent的输出一样。

-e git://github.com/surfly/gevent.git@15418fc8ff4460069cf42b4b0341969c54455ddd#egg=gevent-dev

这对应于gevent的那个版本


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接