pip3 setup.py install_requires PEP 508 git URL 私人回购
pip3 setup.py install_requires PEP 508 git URL for private repo
我正在尝试 运行:
pip3 install -e .
在我的 Python 项目中,我有以下 setup.py
:
from setuptools import setup
setup(
name='mypackage',
install_requires=[
"anotherpackage@git+git@bitbucket.org:myorg/anotherpackage.git"
]
)
但它失败了:
error in mypackage setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid URL given
我想我的 URL 的格式是正确的,因为 PEP 508 不允许为 ssh clone URLs 指定 git 用户名。
使用 git+ssh 协议的 PEP 508 URLs 的正确语法是什么 install_requires
对私有 git 存储库的依赖(在本例中托管在 BitBucket 上) )?指定特定分支、标记或 sha 的语法是什么?
更多上下文以避免 XY 问题
我有一个内部 Python 项目依赖于多个内部开发的 Python 包。我想避免在组织中托管我自己的 PIP 存储库的必要性,因此我尝试直接使用 git URLs。我需要为 git URLs 使用 ssh 协议,因为所有用户都配置了他们的 ssh 密钥,要求所有用户在 BitBuckets 中配置他们的应用程序密码会很麻烦(我需要 2FA 并且普通用户密码无效)。
我已经尝试使用:
dependency_links
setup(
name='mypackage',
install_requires=[
"anotherpackage==0.0.1"
],
dependency_links=[
"git+git@bitbucket.org:myorg/anotherpackage.git@0.0.1#egg=anotherpackage-0.0.1"
]
)
但它们已被弃用并且被 pip3 install -e .
忽略。根据我发现的文档,应该改用 PEP 508 URLs。
requirements.txt
文件,其中的条目从 install_requires
个条目中复制
我有一个 requirements.txt
文件:
-e git+git@bitbucket.org:myorg/anotherpackage.git@0.0.1#egg=anotherpackage
我使用 pip3 install -r requirements.txt
而不是 pip3 install -e .
。它有效但不是最理想的,因为我必须保持 setyp.py
和 requirements.txt
同步。
如果我的问题有任何其他推荐的解决方案,我想了解它:)
在检查 pip
源代码后,我找到了私有 BitBucket 存储库的正确语法。
带有 URLs 的包的一般形式是 <package name>@<URI>
并且 URI 必须以 <scheme>://
.
开头
所以我将其固定为:
anotherpackage@git+ssh://git@bitbucket.org:myorg/anotherpackage.git
然后我得到了一个不同的错误 - 这次 git
命令(由 pip
调用)抱怨存储库 URL ssh://git@bitbucket.org:myorg/anotherpackage.git
.
我检查了 git 文档中的 ssh://
URLs 格式,发现主机名和组织部分必须用 /
而不是 [=19] 分隔=]:
ssh://git@bitbucket.org/myorg/anotherpackage.git
这个 URL 工作正常。我还从 pip
源代码中了解到实际的 revision/branch/tag 可以通过附加 @<rev-spec>
来指定,因此我可以在 [=24] 中使用以下内容指定标签 0.0.1
=]:
anotherpackage@git+ssh://git@bitbucket.org:myorg/anotherpackage.git@0.0.1
我仍然遇到的唯一问题是,当我更改修订版并再次 运行 pip3 install -e .
时,它没有检测到更改(即使 运行 和 --upgrade
).我必须再次手动卸载软件包 (pip3 uninstall anotherpackage
) 和 运行 pip3 install -e .
。
我正在尝试 运行:
pip3 install -e .
在我的 Python 项目中,我有以下 setup.py
:
from setuptools import setup
setup(
name='mypackage',
install_requires=[
"anotherpackage@git+git@bitbucket.org:myorg/anotherpackage.git"
]
)
但它失败了:
error in mypackage setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid URL given
我想我的 URL 的格式是正确的,因为 PEP 508 不允许为 ssh clone URLs 指定 git 用户名。
使用 git+ssh 协议的 PEP 508 URLs 的正确语法是什么 install_requires
对私有 git 存储库的依赖(在本例中托管在 BitBucket 上) )?指定特定分支、标记或 sha 的语法是什么?
更多上下文以避免 XY 问题
我有一个内部 Python 项目依赖于多个内部开发的 Python 包。我想避免在组织中托管我自己的 PIP 存储库的必要性,因此我尝试直接使用 git URLs。我需要为 git URLs 使用 ssh 协议,因为所有用户都配置了他们的 ssh 密钥,要求所有用户在 BitBuckets 中配置他们的应用程序密码会很麻烦(我需要 2FA 并且普通用户密码无效)。
我已经尝试使用:
dependency_links
setup(
name='mypackage',
install_requires=[
"anotherpackage==0.0.1"
],
dependency_links=[
"git+git@bitbucket.org:myorg/anotherpackage.git@0.0.1#egg=anotherpackage-0.0.1"
]
)
但它们已被弃用并且被 pip3 install -e .
忽略。根据我发现的文档,应该改用 PEP 508 URLs。
requirements.txt
文件,其中的条目从 install_requires
个条目中复制
我有一个 requirements.txt
文件:
-e git+git@bitbucket.org:myorg/anotherpackage.git@0.0.1#egg=anotherpackage
我使用 pip3 install -r requirements.txt
而不是 pip3 install -e .
。它有效但不是最理想的,因为我必须保持 setyp.py
和 requirements.txt
同步。
如果我的问题有任何其他推荐的解决方案,我想了解它:)
在检查 pip
源代码后,我找到了私有 BitBucket 存储库的正确语法。
带有 URLs 的包的一般形式是 <package name>@<URI>
并且 URI 必须以 <scheme>://
.
所以我将其固定为:
anotherpackage@git+ssh://git@bitbucket.org:myorg/anotherpackage.git
然后我得到了一个不同的错误 - 这次 git
命令(由 pip
调用)抱怨存储库 URL ssh://git@bitbucket.org:myorg/anotherpackage.git
.
我检查了 git 文档中的 ssh://
URLs 格式,发现主机名和组织部分必须用 /
而不是 [=19] 分隔=]:
ssh://git@bitbucket.org/myorg/anotherpackage.git
这个 URL 工作正常。我还从 pip
源代码中了解到实际的 revision/branch/tag 可以通过附加 @<rev-spec>
来指定,因此我可以在 [=24] 中使用以下内容指定标签 0.0.1
=]:
anotherpackage@git+ssh://git@bitbucket.org:myorg/anotherpackage.git@0.0.1
我仍然遇到的唯一问题是,当我更改修订版并再次 运行 pip3 install -e .
时,它没有检测到更改(即使 运行 和 --upgrade
).我必须再次手动卸载软件包 (pip3 uninstall anotherpackage
) 和 运行 pip3 install -e .
。