使用 pip 安装 Python 包源 tarball
我试图弄清楚如何构建可通过 pip 安装的 Python 源包。我尝试使用 http://packages.python.org 上描述的 setup.py 文件创建一个测试项目/an_example_pypi_project/setuptools.html 以及指定目录下的一些简单的测试文件。
使用 python setup.py sdist 为名为 dist/an_example_pypi_project-0.0.4.tar.gz
的项目创建源 tarball 后,我尝试将其安装在名为的 virtualenv 环境中~/TEST
与 ~/TEST/bin/pip install dist/an_example_pypi_project-0.0.4.tar.gz
。虽然 pip 没有抛出任何错误,但它似乎没有安装该软件包:
$ ~/TEST/bin/pip install dist/an_example_pypi_project-0.0.4.tar.gz
Unpacking ./dist/an_example_pypi_project-0.0.4.tar.gz
Running setup.py egg_info for package from file:///home/lebedov/an_example_pypi_project/dist/an_example_pypi_project-0.0.4.tar.gz
Cleaning up...
$ find ~/TEST -name "an_example*"
$
请注意,我可以使用 easy_install 从 tarball 进行安装:
$ ~/TEST/bin/easy_install dist/an_example_pypi_project-0.0.4.tar.gz
Processing an_example_pypi_project-0.0.4.tar.gz
Running an_example_pypi_project-0.0.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tfXxeW/an_example_pypi_project-0.0.4/egg-dist-tmp-N2QY_N
warning: build_py: byte-compiling is disabled, skipping.
warning: install_lib: byte-compiling is disabled, skipping.
zip_safe flag not set; analyzing archive contents...
Adding an-example-pypi-project 0.0.4 to easy-install.pth file
Installed /home/lebedov/TEST/lib/python2.7/site-packages/an_example_pypi_project-0.0.4-py2.7.egg
Processing dependencies for an-example-pypi-project==0.0.4
Finished processing dependencies for an-example-pypi-project==0.0.4
$ find ~/TEST/ -name "an_example*"
/home/lebedov/TEST/lib/python2.7/site-packages/an_example_pypi_project-0.0.4-py2.7.egg
我是否忽略了在软件包中配置某些内容以使其可以使用 pip 安装?我正在使用 Python 2.7.2、分发 0.6.21、virtualenv 1.7 和 pip 1.0.2。
I'm trying to figure out how to construct a Python source package that is installable via pip. I tried creating a test project with the setup.py file described on http://packages.python.org/an_example_pypi_project/setuptools.html
and a number of simple test files in the specified directories.
After creating a source tarball for the project named dist/an_example_pypi_project-0.0.4.tar.gz
with python setup.py sdist
, I tried installing it in a virtualenv environment called ~/TEST
with~/TEST/bin/pip install dist/an_example_pypi_project-0.0.4.tar.gz
. Although pip didn't throw any error, it didn't seem to install the package:
$ ~/TEST/bin/pip install dist/an_example_pypi_project-0.0.4.tar.gz
Unpacking ./dist/an_example_pypi_project-0.0.4.tar.gz
Running setup.py egg_info for package from file:///home/lebedov/an_example_pypi_project/dist/an_example_pypi_project-0.0.4.tar.gz
Cleaning up...
$ find ~/TEST -name "an_example*"
$
Note that I was able to install from the tarball using easy_install:
$ ~/TEST/bin/easy_install dist/an_example_pypi_project-0.0.4.tar.gz
Processing an_example_pypi_project-0.0.4.tar.gz
Running an_example_pypi_project-0.0.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tfXxeW/an_example_pypi_project-0.0.4/egg-dist-tmp-N2QY_N
warning: build_py: byte-compiling is disabled, skipping.
warning: install_lib: byte-compiling is disabled, skipping.
zip_safe flag not set; analyzing archive contents...
Adding an-example-pypi-project 0.0.4 to easy-install.pth file
Installed /home/lebedov/TEST/lib/python2.7/site-packages/an_example_pypi_project-0.0.4-py2.7.egg
Processing dependencies for an-example-pypi-project==0.0.4
Finished processing dependencies for an-example-pypi-project==0.0.4
$ find ~/TEST/ -name "an_example*"
/home/lebedov/TEST/lib/python2.7/site-packages/an_example_pypi_project-0.0.4-py2.7.egg
Am I neglecting to configure something in the package in order to make it installable with pip? I'm using Python 2.7.2, distribute 0.6.21, virtualenv 1.7, and pip 1.0.2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在 github 上发布的错误报告有很好的重现说明。 (我在票上发表了评论,并在此处复制了回复。)
我使用您列出的软件包的确切版本按照这些说明进行操作,但仍然无法重现此问题。
这是我对相关命令的
pip install --verbose
的输出:也许您可以将
--verbose
添加到您的 pip install 命令中并发布输出以进行比较?The bug report you posted on github had excellent instructions to reproduce. (I commented on the ticket and copied the response here.)
I followed those instructions to the letter using those exact versions of the packages you listed and still can't reproduce this issue.
Here's my output from
pip install --verbose
for the command in question:Maybe you could add
--verbose
to your pip install command and post the output for comparison?