Skip to main content

Artifact Registry tools for Python

This repository contains an alternate keyring backend implementation to help with interacting with Python repositories hosted on Artifact Registry.

Authentication

keyrings.google-artifactregistry-auth is a Python package which allows you to configure keyring to interact with Python repositories stored in Artifact Registry.

The backend automatically searches for credentials from the environment and authenticates to Artifact Registry. It looks for credentials in the following order:

  1. Google Application Default Credentials.
  2. From the gcloud SDK. (i.e., the access token printed via gcloud config config-helper --format='value(credential.access_token)')
    • Hint: You can see which account is active with the command gcloud config config-helper --format='value(configuration.properties.core.account)'
  3. If neither of them exist, an error occurs.

To use the keyring backend:

  1. Log in

    Option 1: log in as a service account:

    (1). Using a JSON file that contains a service account key:

    $ export GOOGLE_APPLICATION_CREDENTIALS=[path/to/key.json]
    

    (2). Or using gcloud:

    $ gcloud auth application-default login
    

    Option 2: log in as an end user via gcloud:

    $ gcloud auth login
    
  2. Configure twine (.pypirc) and pip (pip.conf) tools to connect to the repository. Use the output from the following command:

     $ gcloud artifacts print-settings python
    

    In your .pypirc file add:

    [disutils]
    index-servers =
        REPOSITORY_ID
    
    [REPOSITORY_ID]
    repository = https://LOCATION-python.pkg.dev/PROJECT_ID/REPOSITORY_ID/
    

    In your pip.conf file add:

    [global]
    index-url = https://LOCATION-python.pkg.dev/PROJECT_ID/REPOSITORY_ID/simple/
    
  3. Install the keyrings.google-artifactregistry-auth package

    $ pip install keyrings.google-artifactregistry-auth
    

    List backends to confirm the installation.

    $ keyring --list-backends
    

    The list should include

    • keyrings.gauth.GooglePythonAuth (priority: 9)
    • keyring.backends.chainer.ChainerBackend (priority: -1)
    • keyring.backends.fail.Keyring (priority: 0)

Usage with other tools

Usage with tox

The tox tool is a testing and automation tool.

Because the credential helper needs to be installed before any private dependencies are installed, it needs to be bootstrapped into the tox environment via a plugin.

To do this, specify the keyrings.google-artifactregistry-auth package via the requires requirement in your tox.ini file:

[tox]
envlist = py
requires = keyrings.google-artifactregistry-auth

[testenv]
deps = -r requirements.txt

You can then configure your requirement.txt file to use the Artifact Registry repo as the index:

--index-url https://[REGION]-python.pkg.dev/[PROJECT_ID]/[REPOSITORY]/simple

# mypackage will be installed from the Artifact Registry repository
mypackage

Metadata

Release files for keyrings.google-artifactregistry-auth-test 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keyrings.google-artifactregistry-auth-test 1.1.2
File Size Uploaded
keyrings_google_artifactregistry_auth_test-1.1.2.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for keyrings.google-artifactregistry-auth-test 1.1.2
File Interpreter ABI Platform
keyrings_google_artifactregistry_auth_test-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / keyrings_google_artifactregistry_auth_test-1.1.2.tar.gz

Download URL keyrings_google_artifactregistry_auth_test-1.1.2.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88cb1d1a6ad8e42dcde8a61ece864ca6cd9cbd364bbd876526cb0af7979d6c1c
BLAKE2b-256 checksum
How to use checksums
2291506f782b91f5f9b6ac9d95b1a5a5fcda79195bd8d63b3110ddc3d2556b59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / keyrings_google_artifactregistry_auth_test-1.1.2-py3-none-any.whl

Download URL keyrings_google_artifactregistry_auth_test-1.1.2-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe93b97345b3e57e94993a8e8fa3381310bbf0b91f9aeeca9a9d6c6ca7056eed
BLAKE2b-256 checksum
How to use checksums
908866166518849799bd5b99f137b4b449292f67a0dd5fa0fd60528f159a6172
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page