From 670e9603ee8d61f672c1cbfb18410de70d0f0e47 Mon Sep 17 00:00:00 2001 From: Franco Mariluis <360428+fmariluis@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:40:41 -0300 Subject: [PATCH] add docs for AWS CodeArtifact (#6816) ## Summary This adds explicit information about using `uv` with AWS CodeArtifact (both as an extra index to fetch private packages and also to publish packages using `twine`). ## Test Plan I'm currently using this setup with several private projects that use CodeArtifact. --------- Co-authored-by: Zanie Blue --- .../guides/integration/alternative-indexes.md | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/docs/guides/integration/alternative-indexes.md b/docs/guides/integration/alternative-indexes.md index 6526111bd..e7dd67c57 100644 --- a/docs/guides/integration/alternative-indexes.md +++ b/docs/guides/integration/alternative-indexes.md @@ -56,7 +56,60 @@ $ # Configure the index URL with the username $ export UV_EXTRA_INDEX_URL=https://VssSessionToken@pkgs.dev.azure.com/{organisation}/{project}/_packaging/{feedName}/pypi/simple/ ``` +## AWS CodeArtifact + +uv can install packages from +[AWS CodeArtifact](https://docs.aws.amazon.com/codeartifact/latest/ug/using-python.html). + +The authorization token can be retrieved using the `awscli` tool. + +!!! note + + This guide assumes the AWS CLI has previously been authenticated. + +First, declare some constants for your CodeArtifact repository: + +```bash +export AWS_DOMAIN="" +export AWS_ACCOUNT_ID="" +export AWS_REGION="" +export AWS_CODEARTIFACT_REPOSITORY="" +``` + +Then, retrieve a token from the `awscli`: + +```bash +export AWS_CODEARTIFACT_TOKEN="$( + aws codeartifact get-authorization-token \ + --domain $AWS_DOMAIN \ + --domain-owner $AWS_ACCOUNT_ID \ + --query authorizationToken \ + --output text +)" +``` + +And configure the index URL: + +```bash +export UV_EXTRA_INDEX_URL="https://aws:${AWS_CODEARTIFACT_TOKEN}@${AWS_DOMAIN}-${AWS_ACCOUNT_ID}.d.codeartifact.${AWS_REGION}.amazonaws.com/pypi/${AWS_CODEARTIFACT_REPOSITORY}/simple/" +``` + +### Publishing packages + +If you also want to publish your own packages to AWS CodeArtifact, you can use `twine` as described +in the [publishing guide](../publish.md). You will need to set `TWINE_REPOSITORY_URL` separately +from the credentials: + +```bash +# Configure twine to use AWS CodeArtifact +export TWINE_REPOSITORY_URL="https://${AWS_CODEARTIFACT_TOKEN}@${AWS_DOMAIN}-${AWS_ACCOUNT_ID}.d.codeartifact.${AWS_REGION}.amazonaws.com/pypi/${AWS_CODEARTIFACT_REPOSITORY}/" +export TWINE_USERNAME=aws +export TWINE_PASSWORD="$AWS_CODEARTIFACT_TOKEN" + +# Publish the package +uv run twine upload dist/* +``` + ## Other indexes -uv is also known to work with JFrog's Artifactory, the Google Cloud Artifact Registry, and AWS Code -Artifact. +uv is also known to work with JFrog's Artifactory and the Google Cloud Artifact Registry.