使用pip安装Python包源代码tarball

时间:2011-12-20 18:04:32

标签: python virtualenv setuptools pip distribute

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

使用dist/an_example_pypi_project-0.0.4.tar.gz为名为python setup.py sdist的项目创建源代码tarball后,我尝试在名为~/TEST的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。

1 个答案:

答案 0 :(得分:4)

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