首页 > 解决方案 > 从特定的 github 提交添加 python setuptools 依赖项(而不是 PyPI 包)

问题描述

我尝试了以下安装方法,但没有成功安装具有特定 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 包中的依赖项?

标签: pythongitpipsetuptools

解决方案


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

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

例如

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


推荐阅读