2016-03-29 33 views
0

我有一個Python包配置是這樣的:如何從具體GitHub的HTTPS安裝Python包提交ID

# setup.py 
from setuptools import setup 

setup(
    name='python-package-test', 
    version='0.0.1', 
    packages=['python-package-test'], 

    dependency_links=[ 
     # This repo actually exists 
     'git+https://github.com/nhooey/[email protected]#egg=tendo', 
    ], 
    install_requires=[ 
     'tendo', 
    ], 
) 

當我安裝這個包從setup.py

$ virtualenv --python=python3 .venv && \ 
    source .venv/bin/activate && \ 
    python setup.py install 

$ pip freeze | grep tendo 
tendo==0.2.9 # Note that this is the *correct* version 

它安裝正確的版本tendo

然而,當我在一個Git倉庫上傳這個包,並與pip安裝:

# The GitHub link doesn't exist as it's private 
# and it's different from the repo mentioned above 
virtualenv --python=python3 .venv && \ 
    source .venv/bin/activate && \ 
    pip install git+ssh://[email protected]/nhooey/package.git 

$ pip freeze | grep tendo 
tendo==0.2.8 # Note that this is the *wrong* version 

它安裝的tendo版本錯誤。

爲什麼setup.py的安裝行爲與pip + git不同?

回答

0

用Pip安裝時必須使用--process-dependency-links選項,因爲Pip不再自動處理該選項。

pip install --process-dependency-links 'git+ssh://[email protected]/nhooey/package.git' 

你會覺得匹普將打印警告,或setuptools更新的版本也將忽略dependency_links爲好。