-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update AWS CodeArtifact documentation to cover [[tool.uv.index]]
API
#9867
Comments
UV can be configured to set secrets in environment variables, but I'm unsure if this approach is suitable for AWS. e.g. [[tool.uv.index]]
name = "aws-code"
url = "https://somecompany-123456789012.d.codeartifact.eu-central-1.amazonaws.com/pypi/development/simple/" export UV_INDEX_AWS_CODE_USERNAME=aws
export UV_INDEX_AWS_CODE_PASSWORD=<token> I see that I've modified the twine section in this way. Perhaps I haven't made a mistake?
|
Thanks, it does work! 😃 |
Yeah the index integration docs were community contributed before we supported |
[[tool.uv.index]]
added when using UV_INDEX
and AWS CodeArtifact[[tool.uv.index]]
API
@zanieb Should we update the password authentication part of Google Artifact Registry at the same time? |
Yeah it makes sense to update it all — I don't feel strongly about separate pull requests vs one. |
I was about to open an identical issue, but it seems that writing the index in The workaround I'm currently using is to set it to 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/" When I run
which is exactly what I want, as @FishAlchemist suggested a way to keep the index URL secret while using the new However, after reading the page, I'm unsure how to set it up with this method. According to https://docs.astral.sh/uv/guides/integration/alternative-indexes/#aws-codeartifact I have:
Where should I put each one of these, using the other method? It feels like I'm missing something trivial. |
I think I figured it out, maybe...? [[tool.uv.index]]
name = "custom-name"
url = "https://<AWS_DOMAIN>-<AWS_ACCOUNT_ID>.d.codeartifact.<AWS_REGION>.amazonaws.com/pypi/<AWS_CODEARTIFACT_REPOSITORY>/simple/" Where Then, in export AWS_DOMAIN=
export AWS_ACCOUNT_ID=
export AWS_REGION=
export AWS_CODEARTIFACT_REPOSITORY=
export AWS_CODEARTIFACT_TOKEN="$(
aws codeartifact get-authorization-token \
--domain $AWS_DOMAIN \
--domain-owner $AWS_ACCOUNT_ID \
--region $AWS_REGION \
--query authorizationToken \
--output text
)"
export UV_INDEX_CUSTOM_NAME_USERNAME="aws"
export UV_INDEX_CUSTOM_NAME_PASSWORD="$AWS_CODEARTIFACT_TOKEN" Where:
Am I right? This is slightly counterintuitive, and I agree that it should be added to the documentation. |
@lmanc You seem to be on the right track, and this approach looks reasonable to me. Here’s how I understand it could work: Adding a Package with a Specific Index:
Alternatively:If you’d rather include the index URL directly, you might use a command like this: uv add <PACKAGE_NAME> --index custom_name=https://${AWS_DOMAIN}-${AWS_ACCOUNT_ID}.d.codeartifact.${AWS_REGION}.amazonaws.com/pypi/${AWS_CODEARTIFACT_REPOSITORY}/simple/ This should add the following lines to your [tool.uv.sources]
<PACKAGE_NAME> = { index = "custom-name" }
[[tool.uv.index]]
name = "custom-name"
url = "<INDEX_URL>" Using the Index Exclusively for a Single Library:If you want the index to apply only to the specific library, you could try adding [tool.uv.sources]
<PACKAGE_NAME> = { index = "custom-name" }
[[tool.uv.index]]
name = "custom-name"
url = "<INDEX_URL>"
explicit = true If there’s anything I’ve misunderstood or missed, feel free to correct me. Also, I agree that adding this to the documentation would make things clearer for others encountering similar challenges. 😊
|
I still see an issue with that in my case, where we have pyproject.toml # ...
dependencies = [
"my-package[aws,utils]==3.0.123",
]
[[tool.uv.index]]
name = "aws-codeartifact"
url = "https://company-123456789.d.codeartifact.eu-central-1.amazonaws.com/pypi/development/simple/" When we develop, we export the two following env variables: export UV_INDEX_AWS_CODEARTIFACT_USERNAME=aws
export UV_INDEX_AWS_CODEARTIFACT_PASSWORD="${CODEARTIFACT_TOKEN}" This will create a [[package]]
name = "my-package"
version = "3.0.123"
source = { registry = "https://company-123456789.d.codeartifact.eu-central-1.amazonaws.com/pypi/development/simple/" }
sdist = { url = "https://company-123456789.d.codeartifact.eu-central-1.amazonaws.com/pypi/development/simple/my-package/3.0.123/my-package-3.0.123.tar.gz", hash = "sha256:12345..." }
wheels = [
{ url = "https://company-123456789.d.codeartifact.eu-central-1.amazonaws.com/pypi/development/simple/my-package/3.0.123/my-package-3.0.123-py3-none-any.whl", hash = "sha256:12345..." },
] Now, I'm searching how I could instead use the One way would be to do |
Started a draft to rework the documentation in #10826. The main reason it's in draft is because I won't be able to test AWS CodeArtifact nor Google Artifact Registry until next week, and won't be able to test Azure Artifacts at all. But if someone is able to test the changes before that, especially for Azure Artifacts as I can't, feel free to report what works and what doesn't in the PR. |
Currently, when using
UV_INDEX
and AWS CodeArtifact, a[[tool.uv.index]]
section is automatically added inpyproject.toml
(e.g. when callinguv add pandas
) with the URL that includes the token, which mean I manually have to remove it before doing agit commit
.Here an example of lines generated in
pyproject.toml
when using AWS CodeArtifact:Could there be a way to avoid that?
BTW: the doc https://docs.astral.sh/uv/guides/integration/alternative-indexes/#aws-codeartifact still uses the deprecated
UV_EXTRA_INDEX_URL
instead ofUV_INDEX
.The text was updated successfully, but these errors were encountered: