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 alpha artifacts print-settings pypi
    

    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]
    extra-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

You can then configure your tox.ini file to use the Artifact Registry repo as an extra index, and specify both public and private dependencies:

[testenv]
setenv =
    PIP_EXTRA_INDEX_URL = https://[REGION]-python.pkg.dev/[PROJECT_ID]/[REPOSITORY]/simple
deps =
    # samplepackage will be installed directly from PyPI
    samplepackage
    # mypackage will be installed from the Artifact Registry repository
    mypackage

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file keyrings.google-artifactregistry-auth-0.0.3.tar.gz.

File metadata

  • Download URL: keyrings.google-artifactregistry-auth-0.0.3.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for keyrings.google-artifactregistry-auth-0.0.3.tar.gz
Algorithm Hash digest
SHA256 54f69bc1755b1778bfbc62dd6b9a6c872579db2929c010341582043ce6c9db35
MD5 768f34d048f21a7c3cc42cd4069dbf43
BLAKE2b-256 3c2d36e709f8c8b4c0203c4b9f997bacb34f38fa054e4dda53da0693a9e5b433

See more details on using hashes here.

File details

Details for the file keyrings.google_artifactregistry_auth-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: keyrings.google_artifactregistry_auth-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for keyrings.google_artifactregistry_auth-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 abbda4133107876a948f5ac8da2513fefa47280ca17be48dc7b0c226175d1922
MD5 cc8f71f4a68a8247aed2ef076ff02ea0
BLAKE2b-256 4f0a941d33537b8ea7d91da6c419b459ad9565492c01869a573ef1058c571161

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page