如何从特定的GitHub HTTPS提交I​​D安装Python包

时间:2016-03-29 21:36:18

标签: python pip

我有一个像这样配置的Python包:

# 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/tendo.git@increase-version-0.2.9#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://git@github.com/nhooey/package.git

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

它安装了错误版本的tendo

为什么setup.py安装的行为与pip + git不同?

1 个答案:

答案 0 :(得分:0)

使用Pip安装时必须使用--process-dependency-links选项,因为Pip不再自动处理此事。

pip install --process-dependency-links 'git+ssh://git@github.com/nhooey/package.git'

您认为Pip会打印警告,或setuptools的更新版本也会忽略dependency_links