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.
pip install keyrings-codeartifactVerified import paths — ran on the pinned version, not inferred.
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.
Ensure `keyrings-codeartifact` is installed in the environment where your package manager (pip, twine, etc.) is run. Configure your package manager to point to the CodeArtifact repository URL.
Verify your AWS CLI configuration (`aws sts get-caller-identity`). If issues persist, running `keyring diagnose` can help identify problems with the keyring setup or location of the `keyringrc.cfg` file.
For `uv`, use `uv tool install keyring --with keyrings.codeartifact`. For `pipx`, use `pipx install keyring` and then `pipx inject keyring keyrings.codeartifact` to ensure they share the same virtual environment.
Run `keyring diagnose` to find the exact location of `keyringrc.cfg` on your system. Refer to the `keyrings.codeartifact` documentation for available options and their correct syntax within the `[codeartifact]` section.
If encountering issues specifically on Windows, consider setting `poetry config keyring.enabled false` if using Poetry, or exploring alternatives if a token character limit is suspected to be the root cause. This is a rare edge case, but worth noting.
Ensure your AWS CLI is configured and authenticated, your CodeArtifact repository URL is correctly set in `~/.config/pip/pip.conf` (or `pyproject.toml` for `uv`/`pdm`), and `keyrings.codeartifact` is properly installed. You may need to run `aws codeartifact login --tool pip --domain <DOMAIN> --domain-owner <ACCOUNT_ID> --repository <REPOSITORY>` to refresh your token and configure pip.
Install a suitable keyring backend for your operating system. For Linux, ensure a desktop keyring service like GNOME Keyring or KDE Wallet is running. On macOS, verify Keychain Access permissions. Alternatively, you can install `keyrings.alt` (e.g., `pip install keyrings.alt`) for alternative backend implementations, although some might have security implications.
Refresh your AWS CodeArtifact authentication token by running `aws codeartifact login --tool pip --domain <DOMAIN> --domain-owner <ACCOUNT_ID> --repository <REPOSITORY>`. Verify that your AWS credentials are valid and the IAM user/role has `codeartifact:GetAuthorizationToken` permissions.
First install `keyring` globally via `pipx`, then inject `keyrings.codeartifact` into its environment: `pipx install keyring` followed by `pipx inject keyring keyrings.codeartifact`.