为什么我无法通过手动 *python setup.py install* 获得 *pip install* 的确切结果? [英] How come I can't get the exactly result to *pip install* by manually *python setup.py install*?
问题描述
我喜欢通过 setuptools 来了解 Python 命名空间包背后的神话,这是我所做的测试.
I like to figure out the myth behind Python's namespace packages by setuptools, and here is what I did test.
- 通过
virtualenv
创建虚拟环境. - 在 PyPI 上查找命名空间包.
- 通过
pip install
安装该软件包. - 检查已安装的文件层次结构.
- Make a virtual environment by
virtualenv
. - Find a namespaced package on PyPI.
- Install that package by
pip install
. - Check the installed file hierarchy.
我使用的包是 zope.interface 并且它在以下方面运行良好我的 virtualenv 上的文件层次结构:
The package I played with is zope.interface and it worked well with the following file hierarchy on my virtualenv:
~virenv/.../site-packages/zope.interface-3.8.0-py2.6-nspkg.pth
/zope.interface-3.8.0-py2.6.egg-info/
/zope/
/interface/
/...
一切看起来都很好,我喜欢 zope.interface 作为真正的命名空间包安装的方式(在文件夹 zope 下).
Everything looked fine and I love the way zope.interface got installed as a real namespaced package (under folder zope).
然后,我又做了一个测试,这就是我想请教的问题.我下载了去皮的 zope.interface 源文件.又喜欢手动玩
Then, I did another test and that's the question I would like to ask for your help. I downloaded the tared zope.interface source file. I liked to play it manually again
- 通过
virtualenv
创建虚拟环境. - 将 zope.interface 解压到某个地方.
- 通过
python setup.py install
安装包. - 去检查 site-packages 中发生了什么.
- Make a virtual environment by
virtualenv
. - Untar the zope.interface into somewhere.
- Install the package by
python setup.py install
. - Go check what happened in site-packages.
站点包如下所示:
~virenv/../site-packages/zope.interface-...egg/
/zope/
/__init__.py
/interface/
/EGG-INFO/
问.为什么我无法通过手动 python setup.py install
获得 pip install
的确切结果?
Q. How come I can't get the exactly result to pip install
by manually python setup.py install
?
推荐答案
pip
在内部使用 setup.py
.它只是将附加选项传递给它.要重现 pip
正在做什么,请执行
pip
uses setup.py
internally. It just passes additional option to it. To reproduce what pip
is doing, execute
python setup.py install --single-version-externally-managed
您还可以运行 pip -vv
以查看运行的确切命令.
You can also run pip -vv
to see exactly which commands are run.
这篇关于为什么我无法通过手动 *python setup.py install* 获得 *pip install* 的确切结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!