从特定的github提交而不是PyPI包添加python setuptools依赖项

问题描述

我尝试了以下安装方法,但未成功安装带有git存储库特定提交的python软件包:

$ python3 setup.py install --user

$ pip3 install -e .

$ python3 -m pip install -e .

这里是setup.py

import sys
from setuptools import setup

install_requires = [
    # 'numpy>=1.9.0' # works
    # 'numpy' # works
    # 'git+https://github.com/numpy/numpy' # works
    # 'git+https://github.com/numpy/numpy@4c83c0444c68b89b051f7ef8d8eb1a2276439d78' # does not work
    # 'git+git://github.com/numpy/numpy.git@4c83c0444c68b89b051f7ef8d8eb1a2276439d78' # does not work
    # 'numpy@git+git://github.com/numpy/numpy.git@4c83c04' # installs the "best match" for numpy,not this commit
    # 'numpy @ git+ssh://git@github.com/numpy/numpy@4c83c0444c68b89b051f7ef8d8eb1a2276439d78#egg=numpy' # installs the "best match" for numpy,not this commit
    ]

setup(
      install_requires=install_requires,)

我已经在本地和以root身份更新了pip和setuptools: pip install -U pip setuptools

没有变化。

我扫描了setuptools,pip和其他文档,但没有提供工作结果的示例。

如何使用setuptools将特定git repo的特定提交指定为python包中的依赖项?

解决方法

您可以在此处找到正确的方法: https://python-packaging.readthedocs.io/en/latest/dependencies.html#packages-not-on-pypi

重要的不是提供git存储库的链接,而是提供Github生成的tarball的链接

EG

dependency_links = ['http://github.com/user/repo/tarball/master#egg=package-1.0']