AWS CodeArtifact Keyring Backend

2.1.2 · active · verified Sat Apr 11

The `keyrings.codeartifact` package provides automatic authentication for publishing and consuming Python packages within private PyPI repositories hosted on AWS CodeArtifact. It extends the `keyring` library to automatically inject time-limited access tokens, integrating seamlessly with tools like `pip`, `twine`, `uv`, and `pixi`. It is currently at version 2.1.2 and is actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `keyrings-codeartifact` for use with `pip`. The library integrates automatically once installed, provided your AWS CLI credentials are configured. Users interact with their package manager (`pip`, `twine`, `uv`, `pixi`) normally, and `keyrings.codeartifact` transparently supplies the necessary tokens.

# 1. Install the keyrings-codeartifact package
# pip install keyrings-codeartifact

# 2. Ensure your AWS CLI is configured with appropriate credentials.
#    For example, through ~/.aws/credentials or environment variables (AWS_ACCESS_KEY_ID, etc.).
#    You can verify with: aws sts get-caller-identity

# 3. Configure pip to use your AWS CodeArtifact repository.
#    Replace <DOMAIN>, <ACCOUNT_ID>, <REGION>, <REPOSITORY> with your CodeArtifact details.
#    The 'aws' username is required by CodeArtifact for token-based authentication.
CODEARTIFACT_INDEX_URL = "https://<DOMAIN>-<ACCOUNT_ID>.d.codeartifact.<REGION>.amazonaws.com/pypi/<REPOSITORY>/simple/"

# Example of how pip would implicitly use the keyring backend:
# Assuming 'my-private-package' is in your CodeArtifact repository
# and `keyrings-codeartifact` is installed and AWS credentials are set up.
# This command would use the credential provided by keyrings.codeartifact automatically.
# pip install my-private-package --index-url $CODEARTIFACT_INDEX_URL

# To demonstrate that it doesn't break standard pip operations, you can try installing a public package:
# pip install requests

view raw JSON →