Skip to content

Using alternative package indexes代替パッケージインデックスの使用

While uv uses the official Python Package Index (PyPI) by default, it also supports alternative package indexes. Most alternative indexes require various forms of authentication, which require some initial setup.uvはデフォルトで公式のPython Package Index (PyPI)を使用しますが、 代替パッケージインデックスもサポートしています。ほとんどの代替インデックスはさまざまな 認証形式を必要とし、初期設定が必要です。

Important重要

If using the pip interface, please read the documentation on using multiple indexes in uv — the default behavior is different from pip to prevent dependency confusion attacks, but this means that uv may not find the versions of a package as you'd expect.pipインターフェースを使用している場合は、ドキュメントをお読みください 複数のインデックスの使用 in uv — デフォルトの動作はpipとは異なり、依存関係の混乱攻撃を防ぐためですが、 これによりuvはパッケージのバージョンを期待通りに見つけられない場合があります。

Azure ArtifactsAzure Artifacts

uv can install packages from Azure Artifacts, either by using a Personal Access Token (PAT), or using the keyring package.uvは Azure Artifactsからパッケージをインストールできます。 Personal Access Token (PAT)を使用するか、keyringパッケージを使用します。

To use Azure Artifacts, add the index to your project:Azure Artifactsを使用するには、プロジェクトにインデックスを追加します:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://pkgs.dev.azure.com/<ORGANIZATION>/<PROJECT>/_packaging/<FEED>/pypi/simple/"

Authenticate with an Azure access tokenAzureアクセス トークンで認証する

If there is a personal access token (PAT) available (e.g., $(System.AccessToken) in an Azure pipeline), credentials can be provided via "Basic" HTTP authentication scheme. Include the PAT in the password field of the URL. A username must be included as well, but can be any string.利用可能な個人アクセストークン(PAT)がある場合(例: $(System.AccessToken) Azureパイプライン内で)、 資格情報は「Basic」HTTP認証スキームを介して提供できます。URLのパスワードフィールドにPATを含めてください。 ユーザー名も含める必要がありますが、任意の文字列で構いません。

For example, with the token stored in the $AZURE_ARTIFACTS_TOKEN environment variable, set credentials for the index with:例えば、トークンが$AZURE_ARTIFACTS_TOKEN環境変数に保存されている場合、インデックスの資格情報を次のように設定します:

export UV_INDEX_PRIVATE_REGISTRY_USERNAME=dummy
export UV_INDEX_PRIVATE_REGISTRY_PASSWORD="$AZURE_ARTIFACTS_TOKEN"

Note注意

PRIVATE_REGISTRY should match the name of the index defined in your pyproject.toml.PRIVATE_REGISTRYは、pyproject.tomlで定義されたインデックスの名前と一致する必要があります。

Authenticate with keyring and artifacts-keyring認証する keyringartifacts-keyring

You can also authenticate to Artifacts using keyring package with the artifacts-keyring plugin. Because these two packages are required to authenticate to Azure Artifacts, they must be pre-installed from a source other than Artifacts.また、keyringパッケージを使用してArtifactsに認証することもできます。 artifacts-keyringプラグインを使用します。これらの2つのパッケージはAzure Artifactsに認証するために必要であり、Artifacts以外のソースから事前にインストールする必要があります。

The artifacts-keyring plugin wraps the Azure Artifacts Credential Provider tool. The credential provider supports a few different authentication modes including interactive login — see the tool's documentation for information on configuration.artifacts-keyringプラグインは、 Azure Artifacts Credential Providerツールをラップします。 資格情報プロバイダーは、対話型ログインを含むいくつかの異なる認証モードをサポートしています — 設定に関する情報はツールのドキュメントを参照してください。

uv only supports using the keyring package in subprocess mode. The keyring executable must be in the PATH, i.e., installed globally or in the active environment. The keyring CLI requires a username in the URL, and it must be VssSessionToken.uvは、keyringパッケージをサブプロセスモードでのみサポートしています。 keyring実行可能ファイルはPATHに存在する必要があり、つまり、グローバルにインストールされるか、アクティブな環境にインストールされている必要があります。 keyring CLIはURLにユーザー名を必要とし、それはVssSessionTokenでなければなりません。

# Pre-install keyring and the Artifacts plugin from the public PyPI
uv tool install keyring --with artifacts-keyring

# Enable keyring authentication
export UV_KEYRING_PROVIDER=subprocess

# Set the username for the index
export UV_INDEX_PRIVATE_REGISTRY_USERNAME=VssSessionToken

Note注意

The tool.uv.keyring-provider setting can be used to enable keyring in your uv.toml or pyproject.toml.tool.uv.keyring-provider 設定を使用して、uv.tomlまたはpyproject.tomlでkeyringを有効にできます。

Similarly, the username for the index can be added directly to the index URL.同様に、インデックスのユーザー名をインデックスURLに直接追加できます。

Publishing packages to Azure ArtifactsAzure Artifactsへのパッケージの公開

If you also want to publish your own packages to Azure Artifacts, you can use uv publish as described in the Building and publishing guide.自分のパッケージをAzure Artifactsに公開したい場合は、uv publishを使用できます。 ビルドと公開ガイドに記載されている通りです。

First, add a publish-url to the index you want to publish packages to. For example:まず、パッケージを公開したいインデックスにpublish-urlを追加します。例えば:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://pkgs.dev.azure.com/<ORGANIZATION>/<PROJECT>/_packaging/<FEED>/pypi/simple/"
publish-url = "https://pkgs.dev.azure.com/<ORGANIZATION>/<PROJECT>/_packaging/<FEED>/pypi/upload/"

Then, configure credentials (if not using keyring):次に、資格情報を設定します(keyringを使用しない場合):

$ export UV_PUBLISH_USERNAME=dummy
$ export UV_PUBLISH_PASSWORD="$AZURE_ARTIFACTS_TOKEN"

And publish the package:そして、パッケージを公開します:

$ uv publish --index private-registry

To use uv publish without adding the publish-url to the project, you can set UV_PUBLISH_URL:publish-urlをプロジェクトに追加せずにuv publishを使用するには、UV_PUBLISH_URLを設定できます:

$ export UV_PUBLISH_URL=https://pkgs.dev.azure.com/<ORGANIZATION>/<PROJECT>/_packaging/<FEED>/pypi/upload/
$ uv publish

Note this method is not preferable because uv cannot check if the package is already published before uploading artifacts.この方法は推奨されません。なぜなら、uvはアーティファクトをアップロードする前にパッケージがすでに公開されているかどうかを確認できないからです。

Google Artifact RegistryGoogle Artifact Registry

uv can install packages from Google Artifact Registry, either by using an access token, or using the keyring package.uvは、Google Artifact Registryからパッケージをインストールできます。アクセス トークンを使用するか、keyringパッケージを使用します。

Note注意

This guide assumes that gcloud CLI is installed and authenticated.このガイドでは、gcloud CLIがインストールされ、認証されていることを前提としています。

To use Google Artifact Registry, add the index to your project:Google Artifact Registryを使用するには、プロジェクトにインデックスを追加します:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<REGION>-python.pkg.dev/<PROJECT>/<REPOSITORY>/simple/"

Authenticate with a Google access tokenGoogleアクセストークンで認証する

Credentials can be provided via "Basic" HTTP authentication scheme. Include access token in the password field of the URL. Username must be oauth2accesstoken, otherwise authentication will fail.資格情報は「Basic」HTTP認証スキームを介して提供できます。URLのパスワードフィールドにアクセストークンを含めてください。ユーザー名はoauth2accesstokenでなければならず、そうでない場合は認証に失敗します。

Generate a token with gcloud:gcloudを使用してトークンを生成します:

export ARTIFACT_REGISTRY_TOKEN=$(
    gcloud auth application-default print-access-token
)

Note注意

You might need to pass extra parameters to properly generate the token (like --project), this is a basic example.トークンを正しく生成するために追加のパラメータ(--projectなど)を渡す必要があるかもしれません。これは基本的な例です。

Then set credentials for the index with:次に、インデックスの資格情報を設定します:

export UV_INDEX_PRIVATE_REGISTRY_USERNAME=oauth2accesstoken
export UV_INDEX_PRIVATE_REGISTRY_PASSWORD="$ARTIFACT_REGISTRY_TOKEN"

Note注意

PRIVATE_REGISTRY should match the name of the index defined in your pyproject.toml.PRIVATE_REGISTRYは、あなたのpyproject.tomlで定義されたインデックスの名前と一致する必要があります。

Authenticate with keyring and keyrings.google-artifactregistry-authkeyringおよびkeyrings.google-artifactregistry-authで認証する

You can also authenticate to Artifact Registry using keyring package with the keyrings.google-artifactregistry-auth plugin. Because these two packages are required to authenticate to Artifact Registry, they must be pre-installed from a source other than Artifact Registry.また、keyringパッケージを使用してArtifact Registryに認証することもできます。 keyrings.google-artifactregistry-authプラグインを使用します。 これらの2つのパッケージはArtifact Registryに認証するために必要であり、Artifact Registry以外のソースから事前にインストールされている必要があります。

The keyrings.google-artifactregistry-auth plugin wraps gcloud CLI to generate short-lived access tokens, securely store them in system keyring, and refresh them when they are expired.keyrings.google-artifactregistry-auth プラグインは、gcloud CLI をラップして、短命のアクセストークンを生成し、それをシステムのキーチェーンに安全に保存し、期限切れの際にはそれを更新します。

uv only supports using the keyring package in subprocess mode. The keyring executable must be in the PATH, i.e., installed globally or in the active environment. The keyring CLI requires a username in the URL and it must be oauth2accesstoken.uv は keyring パッケージを サブプロセスモード でのみサポートしています。keyring 実行可能ファイルは PATH に存在する必要があり、つまり、グローバルにインストールされているか、アクティブな環境にインストールされている必要があります。keyring CLI には URL にユーザー名が必要で、oauth2accesstoken でなければなりません。

# Pre-install keyring and Artifact Registry plugin from the public PyPI
uv tool install keyring --with keyrings.google-artifactregistry-auth

# Enable keyring authentication
export UV_KEYRING_PROVIDER=subprocess

# Set the username for the index
export UV_INDEX_PRIVATE_REGISTRY_USERNAME=oauth2accesstoken

Note注意

The tool.uv.keyring-provider setting can be used to enable keyring in your uv.toml or pyproject.toml.tool.uv.keyring-provider 設定を使用して、uv.toml または pyproject.toml でキーチェーンを有効にすることができます。

Similarly, the username for the index can be added directly to the index URL.同様に、インデックスのユーザー名をインデックス URL に直接追加することができます。

Publishing packages to Google Artifact RegistryGoogle Artifact Registry へのパッケージの公開

If you also want to publish your own packages to Google Artifact Registry, you can use uv publish as described in the Building and publishing guide.自分のパッケージを Google Artifact Registry に公開したい場合は、uv publish を使用できます。これは ビルドと公開ガイド に記載されています。

First, add a publish-url to the index you want to publish packages to. For example:まず、パッケージを公開したいインデックスに publish-url を追加します。例えば:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<REGION>-python.pkg.dev/<PROJECT>/<REPOSITORY>/simple/"
publish-url = "https://<REGION>-python.pkg.dev/<PROJECT>/<REPOSITORY>/"

Then, configure credentials (if not using keyring):次に、資格情報を設定します(キーチェーンを使用しない場合):

$ export UV_PUBLISH_USERNAME=oauth2accesstoken
$ export UV_PUBLISH_PASSWORD="$ARTIFACT_REGISTRY_TOKEN"

And publish the package:そして、パッケージを公開します:

$ uv publish --index private-registry

To use uv publish without adding the publish-url to the project, you can set UV_PUBLISH_URL:publish-url をプロジェクトに追加せずに uv publish を使用するには、UV_PUBLISH_URL を設定できます:

$ export UV_PUBLISH_URL=https://<REGION>-python.pkg.dev/<PROJECT>/<REPOSITORY>/
$ uv publish

Note this method is not preferable because uv cannot check if the package is already published before uploading artifacts.この方法は好ましくありません。なぜなら、uvはパッケージがすでに公開されているかどうかを確認できないからです アーティファクトをアップロードする前に。

AWS CodeArtifactAWS CodeArtifact

uv can install packages from AWS CodeArtifact, either by using an access token, or using the keyring package.uvは、AWS CodeArtifactからパッケージをインストールできます。アクセス・トークンを使用するか、keyringパッケージを使用します。

Note注意

This guide assumes that awscli is installed and authenticated.このガイドでは、awscliがインストールされ、認証されていることを前提としています。

The index can be declared like so:インデックスは次のように宣言できます:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<DOMAIN>-<ACCOUNT_ID>.d.codeartifact.<REGION>.amazonaws.com/pypi/<REPOSITORY>/simple/"

Authenticate with an AWS access tokenAWSアクセス・トークンで認証する

Credentials can be provided via "Basic" HTTP authentication scheme. Include access token in the password field of the URL. Username must be aws, otherwise authentication will fail.資格情報は「Basic」HTTP認証スキームを介して提供できます。URLのパスワードフィールドにアクセス・トークンを含めてください。ユーザー名はawsでなければならず、そうでない場合は認証に失敗します。

Generate a token with awscli:awscliを使用してトークンを生成します:

export AWS_CODEARTIFACT_TOKEN="$(
    aws codeartifact get-authorization-token \
    --domain <DOMAIN> \
    --domain-owner <ACCOUNT_ID> \
    --query authorizationToken \
    --output text
)"

Note注意

You might need to pass extra parameters to properly generate the token (like --region), this is a basic example.トークンを適切に生成するために追加のパラメータ(例えば--region)を渡す必要があるかもしれません。これは基本的な例です。

Then set credentials for the index with:次に、インデックスの資格情報を設定します:

export UV_INDEX_PRIVATE_REGISTRY_USERNAME=aws
export UV_INDEX_PRIVATE_REGISTRY_PASSWORD="$AWS_CODEARTIFACT_TOKEN"

Note注意

PRIVATE_REGISTRY should match the name of the index defined in your pyproject.toml.PRIVATE_REGISTRY は、あなたの pyproject.toml に定義されたインデックスの名前と一致する必要があります。

Authenticate with keyring and keyrings.codeartifactkeyringkeyrings.codeartifact を使用して認証する

You can also authenticate to Artifact Registry using keyring package with the keyrings.codeartifact plugin. Because these two packages are required to authenticate to Artifact Registry, they must be pre-installed from a source other than Artifact Registry.また、keyring パッケージを使用して Artifact Registry に認証することもできます。 keyrings.codeartifact プラグインを使用します。 これらの2つのパッケージは Artifact Registry に認証するために必要であり、Artifact Registry 以外のソースから事前にインストールされている必要があります。

The keyrings.codeartifact plugin wraps boto3 to generate short-lived access tokens, securely store them in system keyring, and refresh them when they are expired.keyrings.codeartifact プラグインは、boto3 をラップして、 短命のアクセストークンを生成し、それをシステムのキーレリングに安全に保存し、期限切れの際に更新します。

uv only supports using the keyring package in subprocess mode. The keyring executable must be in the PATH, i.e., installed globally or in the active environment. The keyring CLI requires a username in the URL and it must be aws.uv は keyring パッケージを サブプロセスモード でのみサポートしています。keyring 実行可能ファイルは PATH に存在する必要があり、つまり、グローバルにインストールされているか、アクティブな環境にインストールされている必要があります。keyring CLI は URL にユーザー名を必要とし、それは aws でなければなりません。

# Pre-install keyring and AWS CodeArtifact plugin from the public PyPI
uv tool install keyring --with keyrings.codeartifact

# Enable keyring authentication
export UV_KEYRING_PROVIDER=subprocess

# Set the username for the index
export UV_INDEX_PRIVATE_REGISTRY_USERNAME=aws

Note注意

The tool.uv.keyring-provider setting can be used to enable keyring in your uv.toml or pyproject.toml.tool.uv.keyring-provider 設定を使用して、あなたの uv.toml または pyproject.toml でキーレリングを有効にすることができます。

Similarly, the username for the index can be added directly to the index URL.同様に、インデックスのユーザー名をインデックス URL に直接追加することができます。

Publishing packages to AWS CodeArtifactAWS CodeArtifact へのパッケージの公開

If you also want to publish your own packages to AWS CodeArtifact, you can use uv publish as described in the Building and publishing guide.自分のパッケージを AWS CodeArtifact に公開したい場合は、uv publish を使用できます。 ビルドと公開ガイドに記載されているように。

First, add a publish-url to the index you want to publish packages to. For example:まず、パッケージを公開したいインデックスに publish-url を追加します。例えば:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<DOMAIN>-<ACCOUNT_ID>.d.codeartifact.<REGION>.amazonaws.com/pypi/<REPOSITORY>/simple/"
publish-url = "https://<DOMAIN>-<ACCOUNT_ID>.d.codeartifact.<REGION>.amazonaws.com/pypi/<REPOSITORY>/"

Then, configure credentials (if not using keyring):次に、資格情報を設定します(keyringを使用しない場合):

$ export UV_PUBLISH_USERNAME=aws
$ export UV_PUBLISH_PASSWORD="$AWS_CODEARTIFACT_TOKEN"

And publish the package:パッケージを公開します:

$ uv publish --index private-registry

To use uv publish without adding the publish-url to the project, you can set UV_PUBLISH_URL:uv publishをプロジェクトにpublish-urlを追加せずに使用するには、UV_PUBLISH_URLを設定できます:

$ export UV_PUBLISH_URL=https://<DOMAIN>-<ACCOUNT_ID>.d.codeartifact.<REGION>.amazonaws.com/pypi/<REPOSITORY>/
$ uv publish

Note this method is not preferable because uv cannot check if the package is already published before uploading artifacts.この方法は、uvがアーティファクトをアップロードする前にパッケージがすでに公開されているかどうかを確認できないため、推奨されません。

JFrog ArtifactoryJFrog Artifactory

uv can install packages from JFrog Artifactory, either by using a username and password or a JWT token.uvは、ユーザー名とパスワードまたはJWTトークンを使用して、JFrog Artifactoryからパッケージをインストールできます。

To use it, add the index to your project:使用するには、インデックスをプロジェクトに追加します:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<organization>.jfrog.io/artifactory/api/pypi/<repository>/simple"

Authenticate with username and passwordユーザー名とパスワードで認証する

$ export UV_INDEX_PRIVATE_REGISTRY_USERNAME="<username>"
$ export UV_INDEX_PRIVATE_REGISTRY_PASSWORD="<password>"

Authenticate with JWT tokenJWTトークンで認証する

$ export UV_INDEX_PRIVATE_REGISTRY_USERNAME=""
$ export UV_INDEX_PRIVATE_REGISTRY_PASSWORD="$JFROG_JWT_TOKEN"

Note注意

Replace PRIVATE_REGISTRY in the environment variable names with the actual index name defined in your pyproject.toml.環境変数名のPRIVATE_REGISTRYを、pyproject.tomlで定義された実際のインデックス名に置き換えてください。

Publishing packages to JFrog ArtifactoryJFrog Artifactoryへのパッケージの公開

Add a publish-url to your index definition:インデックス定義にpublish-urlを追加します:

pyproject.toml
[[tool.uv.index]]
name = "private-registry"
url = "https://<organization>.jfrog.io/artifactory/api/pypi/<repository>/simple"
publish-url = "https://<organization>.jfrog.io/artifactory/api/pypi/<repository>"

Important重要

If you use --token "$JFROG_TOKEN" or UV_PUBLISH_TOKEN with JFrog, you will receive a 401 Unauthorized error as JFrog requires an empty username but uv passes __token__ for as the username when --token is used.JFrogで--token "$JFROG_TOKEN"またはUV_PUBLISH_TOKENを使用すると、401 Unauthorizedエラーが発生します。JFrogは空のユーザー名を要求しますが、uvは--tokenが使用されるときにユーザー名として__token__を渡します。

To authenticate, pass your token as the password and set the username to an empty string:認証するには、トークンをパスワードとして渡し、ユーザー名を空の文字列に設定します:

$ uv publish --index <index_name> -u "" -p "$JFROG_TOKEN"

Alternatively, you can set environment variables:または、環境変数を設定することもできます:

$ export UV_PUBLISH_USERNAME=""
$ export UV_PUBLISH_PASSWORD="$JFROG_TOKEN"
$ uv publish --index private-registry

Note注意

The publish environment variables (UV_PUBLISH_USERNAME and UV_PUBLISH_PASSWORD) do not include the index name.公開環境変数(UV_PUBLISH_USERNAMEおよびUV_PUBLISH_PASSWORD)にはインデックス名は含まれません。