如何使用诗歌添加私有存储库?

问题描述 投票:0回答:1

使用Artifactory(https://cloud.google.com/artifact-registry)我打算添加对诗歌的依赖(https://python-poetry.org/docs/repositories/)。

我可以使用命令安装:

pip install --index-url https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/ <PACKAGE_NAME>
(使用 keyrings.google-artifactregistry-auth 进行身份验证)

我打算使用 POETRY 来管理我的依赖项。我不知道使用诗歌是否会增加这种依赖性。使用

poetry add --source <PACKAGE_NAME> https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>
我收到此错误:

poetry update
Updating dependencies
Resolving dependencies... (0.9s)

  RepositoryError

  401 Client Error: Unauthorized for url: https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/pytest/

我的 pyproject.toml

...

[[tool.poetry.source]]
name = "SOME_LIB"
url = " https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/"
secondary = true

这里详细介绍了如何使用 PIP/VIRTUALENV 进行配置:https://cloud.google.com/artifact-registry/docs/python/authentication 但没有有关 Poetry 的详细信息。

你对此有什么建议吗?

python python-packaging python-poetry google-artifact-registry
1个回答
0
投票

首先,您需要创建一个“补充”源。这是 PyPI 之后将查询的注册表(默认)。在下面的示例中,我们将新源称为

foo
:

poetry source add --priority=supplemental foo https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/

这会将以下块附加到您的

pyproject.toml

[[tool.poetry.source]]
name = "foo"
url = "https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/"
priority = "supplemental"

其次,将 GCP 身份验证凭据添加到诗歌中:

poetry self add keyrings.google-artifactregistry-auth

最后,在将新依赖项添加到

pyproject.toml
时指定来源:

poetry add --source foo private-package

有关更多信息,请参阅诗歌文档

© www.soinside.com 2019 - 2024. All rights reserved.