Google Auth令牌的密钥环后端
项目描述
Python的Artifact Registry工具
此存储库包含一个替代的keyring后端实现,以帮助与在Artifact Registry上托管的Python存储库交互。
身份验证
keyrings.google-artifactregistry-auth
是一个Python包,允许您配置密钥环以与存储在Artifact Registry中的Python存储库交互。
后端自动从环境中搜索凭据并验证到Artifact Registry。它会按照以下顺序查找凭据
- Google应用程序默认凭据.
- 来自
gcloud
SDK。(即,通过gcloud config config-helper --format='value(credential.access_token)'
打印的访问令牌)- 提示:您可以使用以下命令查看哪个账户处于活动状态:
gcloud config config-helper --format='value(configuration.properties.core.account)'
- 提示:您可以使用以下命令查看哪个账户处于活动状态:
- 如果它们都不存在,则会发生错误。
要使用密钥环后端
-
登录
选项1:以服务账户登录
(1)使用包含服务账户密钥的JSON文件
$ export GOOGLE_APPLICATION_CREDENTIALS=[path/to/key.json]
(2)或使用
gcloud
$ gcloud auth application-default login
选项2:通过
gcloud
以最终用户身份登录$ gcloud auth login
-
配置twine(
.pypirc
)和pip(pip.conf
)工具以连接到存储库。使用以下命令的输出$ gcloud artifacts print-settings python
在您的
.pypirc
文件中添加[disutils] index-servers = REPOSITORY_ID [REPOSITORY_ID] repository = https://LOCATION-python.pkg.dev/PROJECT_ID/REPOSITORY_ID/
在您的
pip.conf
文件中添加[global] extra-index-url = https://LOCATION-python.pkg.dev/PROJECT_ID/REPOSITORY_ID/simple/
-
安装
keyrings.google-artifactregistry-auth
软件包$ pip install keyrings.google-artifactregistry-auth
列出后端以确认安装。
$ keyring --list-backends
列表应包括
keyrings.gauth.GooglePythonAuth (优先级:9)
keyring.backends.chainer.ChainerBackend (优先级:-1)
keyring.backends.fail.Keyring (优先级:0)
与其他工具的使用
与 tox
的使用
tox
工具 是一个测试和自动化工具。
由于凭证助手需要在安装任何私有依赖项之前安装,因此需要通过插件将其引导到 tox
环境中。
为此,请在您的 tox.ini
文件中通过 requires
依赖项指定 keyrings.google-artifactregistry-auth
软件包
[tox]
envlist = py
requires = keyrings.google-artifactregistry-auth
[testenv]
deps = -r requirements.txt
然后,您可以将您的 requirement.txt
文件配置为使用 Artifactory 仓库作为额外索引,并指定公共和私有依赖项
--extra-index-url https://[REGION]-python.pkg.dev/[PROJECT_ID]/[REPOSITORY]/simple
# samplepackage will be installed directly from PyPI
samplepackage
# mypackage will be installed from the Artifact Registry repository
mypackage
项目详细信息
关闭
keyrings.google-artifactregistry-auth-1.1.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bd6abb72740d2dfeb4a5c03c3b105c6f7dba169caa29dee3959694f1f02c77de |
|
MD5 | cd46b4365f7cf7938b6d20724222d965 |
|
BLAKE2b-256 | 62e63b1803862ca29534aafe94a0d73756435116f8d302e5b482bce637634cb2 |
关闭
keyrings.google_artifactregistry_auth-1.1.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e3f18b50fa945c786593014dc225810d191671d4f5f8e12d9259e39bad3605a3 |
|
MD5 | e13aa6f88d64048cccb6106ee17fa4bc |
|
BLAKE2b-256 | dca09698d906772b8c445f502e30c9408314998b29a0ee9fb22d849433a8146b |