14

我试图弄清楚如何构建一个可通过 pip 安装的 Python 源包。我尝试使用http://packages.python.org/an_example_pypi_project/setuptools.html上描述的 setup.py 文件 和指定目录中的一些简单测试文件创建一个测试项目。

dist/an_example_pypi_project-0.0.4.tar.gz在为名为with的项目创建源 tarball 后python setup.py sdist,我尝试将其安装在名为~/TESTwith 的 virtualenv 环境中~/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。

4

1 回答 1

5

您在 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 命令并发布输出以进行比较?

于 2012-02-23T08:54:52.703 回答