使用 pip 安装 Python 包源 tarball

发布于 2024-12-22 07:09:49 字数 1977 浏览 6 评论 0原文

我试图弄清楚如何构建可通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不…忘初心 2024-12-29 07:09:49

您在 github 上发布的错误报告有很好的重现说明。 (我在票上发表了评论,并在此处复制了回复。)

我使用您列出的软件包的确切版本按照这些说明进行操作,但仍然无法重现此问题。

这是我对相关命令的 pip install --verbose 的输出:

Unpacking ./dist/anyjson-0.3.1.tar.gz
  Running setup.py egg_info for package from file:///home/david/projects/anyjson-0.3.1/dist/anyjson-0.3.1.tar.gz
    running egg_info
    creating pip-egg-info/anyjson.egg-info
    writing pip-egg-info/anyjson.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/anyjson.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/anyjson.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
Installing collected packages: anyjson
  Running setup.py install for anyjson
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.7
    creating build/lib.linux-i686-2.7/anyjson
    copying anyjson/__init__.py -> build/lib.linux-i686-2.7/anyjson
    running install_lib
    creating /tmp/TEST/lib/python2.7/site-packages/anyjson
    copying build/lib.linux-i686-2.7/anyjson/__init__.py -> /tmp/TEST/lib/python2.7/site-packages/anyjson
    byte-compiling /tmp/TEST/lib/python2.7/site-packages/anyjson/__init__.py to __init__.pyc
    running install_egg_info
    running egg_info
    writing anyjson.egg-info/PKG-INFO
    writing top-level names to anyjson.egg-info/top_level.txt
    writing dependency_links to anyjson.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'anyjson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'anyjson.egg-info/SOURCES.txt'
    Copying anyjson.egg-info to /tmp/TEST/lib/python2.7/site-packages/anyjson-0.3.1-py2.7.egg-info
    running install_scripts
    writing list of installed files to '/tmp/pip-gvBT02-record/install-record.txt'
Successfully installed anyjson
Cleaning up...

也许您可以将 --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:

Unpacking ./dist/anyjson-0.3.1.tar.gz
  Running setup.py egg_info for package from file:///home/david/projects/anyjson-0.3.1/dist/anyjson-0.3.1.tar.gz
    running egg_info
    creating pip-egg-info/anyjson.egg-info
    writing pip-egg-info/anyjson.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/anyjson.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/anyjson.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/anyjson.egg-info/SOURCES.txt'
Installing collected packages: anyjson
  Running setup.py install for anyjson
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.7
    creating build/lib.linux-i686-2.7/anyjson
    copying anyjson/__init__.py -> build/lib.linux-i686-2.7/anyjson
    running install_lib
    creating /tmp/TEST/lib/python2.7/site-packages/anyjson
    copying build/lib.linux-i686-2.7/anyjson/__init__.py -> /tmp/TEST/lib/python2.7/site-packages/anyjson
    byte-compiling /tmp/TEST/lib/python2.7/site-packages/anyjson/__init__.py to __init__.pyc
    running install_egg_info
    running egg_info
    writing anyjson.egg-info/PKG-INFO
    writing top-level names to anyjson.egg-info/top_level.txt
    writing dependency_links to anyjson.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'anyjson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'anyjson.egg-info/SOURCES.txt'
    Copying anyjson.egg-info to /tmp/TEST/lib/python2.7/site-packages/anyjson-0.3.1-py2.7.egg-info
    running install_scripts
    writing list of installed files to '/tmp/pip-gvBT02-record/install-record.txt'
Successfully installed anyjson
Cleaning up...

Maybe you could add --verbose to your pip install command and post the output for comparison?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文