gpt4 book ai didi

python - 如何编写 setup.py 以包含 Git 存储库作为依赖项

转载 作者:IT老高 更新时间:2023-10-28 20:29:56 26 4
gpt4 key购买 nike

我正在尝试为我的包编写 setup.py。我的包需要指定对另一个 Git 存储库的依赖。

这是我目前所拥有的:

from setuptools import setup, find_packages

setup(
name='abc',
packages=find_packages(),
url='https://github.abc.com/abc/myabc',
description='This is a description for abc',
long_description=open('README.md').read(),
install_requires=[
"requests==2.7.0",
"SomePrivateLib>=0.1.0",
],
dependency_links = [
"git+git://github.abc.com/abc/SomePrivateLib.git#egg=SomePrivateLib",
],
include_package_data=True,
)

当我运行时:

pip install -e https://github.abc.com/abc/myabc.git#egg=analyse

我明白了

Could not find a version that satisfies the requirementSomePrivateLib>=0.1.0 (from analyse) (from versions: ) No matchingdistribution found for SomePrivateLib>=0.1.0 (from analyse)

我做错了什么?

最佳答案

在挖掘 pip issue 3939 之后在上面的评论中由@muon 链接,然后是PEP-508 specification ,我发现使用 install_requires 中的规范模式通过 setup.py 成功安装了我的私有(private) repo 依赖项(不再有 dependency_links):

install_requires = [
'some-pkg @ git+ssh://git@github.com/someorgname/pkg-repo-name@v1.1#egg=some-pkg',
]

@v1.1 表示在 github 上创建的发布标签,可以替换为分支、提交或其他类型的标签。

关于python - 如何编写 setup.py 以包含 Git 存储库作为依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32688688/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com