2011-12-20 127 views
12

我想弄清楚如何構建可通過pip安裝的Python源碼包。我嘗試使用在http://packages.python.org/an_example_pypi_project/setuptools.html 上描述的setup.py文件和指定目錄中的許多簡單測試文件創建一個測試項目。用pip安裝Python軟件包源碼包

創建名爲dist/an_example_pypi_project-0.0.4.tar.gzpython setup.py sdist項目源壓縮包後,我嘗試安裝它在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能夠從壓縮包安裝:

$ ~/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

這個問題似乎只在我調用pip時出現,而當前目錄是包含項目源的目錄。看起來,構建源代碼發佈之後創建的.egg-info子目錄的存在會混淆pip。不知道這是否是一個錯誤 - 我會問問小開發者。 – lebedov 2011-12-20 18:35:52

+2

爲了將來的參考,這裏是查詢:https://github.com/pypa/pip/issues/414 – lebedov 2011-12-20 18:51:22

+0

這適用於我的項目,我也有.egg-info。你有沒有用'tree'來看看你的目錄? – 2011-12-27 17:57:15

回答

4

你發佈在github上的bug報告有很好的重現指令。 (我在票上評論過,並在這裏複製了回覆。)

我按照這些說明使用了列出的軟件包的確切版本,但仍然無法重現此問題。

下面是從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到您的點子安裝命令後輸出進行比較?

+1

我有一個類似的問題。我在我的.bashrc文件中註釋掉了PYTHONDONTWRITEBYTECODE,註銷,登錄,啓動了我的虛擬環境,pip安裝正常運行。 – highpost 2014-01-07 22:42:49