python - 从特定的 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 包中的依赖项?
解决方案
您可以在这里找到正确的方法: 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']
推荐阅读
- python - 用汤解析数字试图将其变成一个 int
- vb.net - 如何将输入保存到我的基于服务的数据库中?
- javascript - Flutter WebView blob pdf 下载
- arrays - PowerShell Invoke-RestMethod 在浏览数组值时会跳过返回的空值。想法?
- opencv - 对于包含多通道数据的 3D cv::Mat,数据如何在内存中布局?
- flutter - 创建包含小部件颤振列表的模型
- node.js - 如何将文件附加到使用 Courier 通过 AWS SES 发送的电子邮件?
- reactjs - 使用 styled-jsx 而不弹出 create-react-app
- javascript - 使用 Selenium 在 Headless Chrome 中全屏显示
- apache-flink - 如何在 flink 1.8 中检查 MapState 是否为空