Skip to main content

Using pipenv

1. Add private index in Pipfile

You can get the token using AWS CLI command and then use it to set index URL in Pipfile.

Use an environment variable (CODEARTIFACT_AUTH_TOKEN) to store the credentials and use it safely within Pipfile.

[packages]
example-package-hello = {version = "*", index = "neev"}

[dev-packages]

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "https://aws:${CODEARTIFACT_AUTH_TOKEN}@neev-529730085565.d.codeartifact.eu-west-2.amazonaws.com/pypi/pypi/simple"
verify_ssl = false
name = "neev"

2. Installing packages

Make sure to set CODEARTIFACT_AUTH_TOKEN env variable with Codeartifact token

export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain neev --domain-owner 529730085565 --query authorizationToken --output text --region eu-west-2`

More details on getting the authorization token.

tip

If you get "An error occurred (ResourceNotFoundException) when calling the GetAuthorizationToken operation: Domain not found. Domain 'neev' owned by account '529730085565' does not exist."
Then make sure the aws cli has been set with an account in the o-akodnm2nsf org id. (ECS org).

caution

The token is valid for 12 hours by default. You'll need to call this command again to get a new token.

If you have added the neev index in Pipfile, you can now install packages from neev index.

pipenv install example-package-math --index neev

caution

Install/upgrade and use latest pipenv (>=2022.3.23). Older versions of pipenv does not respect index attribute of package in Pipfile and may try to download package from public index even if an index is explicitly specified.

[packages]
example-package-hello = {version = "*", index = "neev"}
...

See issue 4637