我有一个目录~/foo
,其中只有setup.py
,其中包含:
from setuptools import setup, find_packages
setup(
name='foo',
version='0.1',
packages=find_packages(),
install_requires=['mock']
)
现在,我使用以下方法创建虚拟环境:
cd ~
virtualenv --system-site-packages v1
做~/v1/bin/python -c "import sys; print sys.path"
,我得
['',
'/home/garrett',
'/home/garrett/v1/lib/python2.7',
'/home/garrett/v1/lib/python2.7/plat-x86_64-linux-gnu',
'/home/garrett/v1/lib/python2.7/lib-tk',
'/home/garrett/v1/lib/python2.7/lib-old',
'/home/garrett/v1/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/garrett/v1/local/lib/python2.7/site-packages',
'/home/garrett/v1/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
但是,当我这样做时
sudo pip install mock
cd ~/foo
~/v1/bin/python setup.py develop
然后setuptools将我的virtualenv sys.path
更改为靠近顶部的dist-packages
(其中mock
生活)。即,sys.path
的前3个条目变为:
['',
'/usr/local/lib/python2.7/dist-packages',
'/home/garrett/foo',
...
通过查看修改easy-install.pth
的{{3}},这似乎是有意的。
无论如何要禁用它会弄乱我dist-packages
中sys.path
的位置?我的dist-packages
目录中包含其他模块,这些模块被赋予了不必要的优先权。
答案 0 :(得分:0)
不确定这是否是最佳解决方案,但阻止setuptools提供dist_packages
更高优先级的一种方法是添加--always-copy
标志。
~/v1/bin/python setup.py develop --always-copy