Skip to content

Configuration files設定ファイル

uv supports persistent configuration files at both the project- and user-level.uvは、プロジェクトレベルとユーザーレベルの両方で永続的な設定ファイルをサポートしています。

Specifically, uv will search for a pyproject.toml or uv.toml file in the current directory, or in the nearest parent directory.具体的には、uvは現在のディレクトリまたは最も近い親ディレクトリにあるpyproject.tomlまたはuv.tomlファイルを検索します。

Note注意

For tool commands, which operate at the user level, local configuration files will be ignored. Instead, uv will exclusively read from user-level configuration (e.g., ~/.config/uv/uv.toml) and system-level configuration (e.g., /etc/uv/uv.toml).toolコマンドはユーザーレベルで動作するため、ローカル設定ファイルは無視されます。代わりに、uvはユーザーレベルの設定(例:~/.config/uv/uv.toml)とシステムレベルの設定(例:/etc/uv/uv.toml)からのみ読み取ります。

In workspaces, uv will begin its search at the workspace root, ignoring any configuration defined in workspace members. Since the workspace is locked as a single unit, configuration is shared across all members.ワークスペースでは、uvはワークスペースのルートから検索を開始し、ワークスペースメンバーで定義された設定は無視されます。ワークスペースは単一のユニットとしてロックされているため、設定はすべてのメンバー間で共有されます。

If a pyproject.toml file is found, uv will read configuration from the [tool.uv] table. For example, to set a persistent index URL, add the following to a pyproject.toml:もしpyproject.tomlファイルが見つかった場合、uvは[tool.uv]テーブルから設定を読み取ります。例えば、永続的なインデックスURLを設定するには、次の内容をpyproject.tomlに追加します:

pyproject.toml
[[tool.uv.index]]
url = "https://test.pypi.org/simple"
default = true

(If there is no such table, the pyproject.toml file will be ignored, and uv will continue searching in the directory hierarchy.)(そのようなテーブルが存在しない場合、pyproject.tomlファイルは無視され、uvはディレクトリ階層内での検索を続けます。)

uv will also search for uv.toml files, which follow an identical structure, but omit the [tool.uv] prefix. For example:uvはまた、uv.tomlファイルも検索します。これらは同じ構造に従いますが、[tool.uv]プレフィックスを省略します。例えば:

uv.toml
[[index]]
url = "https://test.pypi.org/simple"
default = true

Note注意

uv.toml files take precedence over pyproject.toml files, so if both uv.toml and pyproject.toml files are present in a directory, configuration will be read from uv.toml, and [tool.uv] section in the accompanying pyproject.toml will be ignored.uv.tomlファイルはpyproject.tomlファイルよりも優先されるため、両方のuv.tomlpyproject.tomlファイルがディレクトリ内に存在する場合、設定はuv.tomlから読み取られ、付随するpyproject.toml内の[tool.uv]セクションは無視されます。

uv will also discover uv.toml configuration files in the user- and system-level configuration directories, e.g., user-level configuration in ~/.config/uv/uv.toml, and system-level configuration at /etc/uv/uv.toml on macOS and Linux.uvはまた、ユーザーおよびシステムレベルのuv.toml設定ファイルを設定ディレクトリ内で発見します。例えば、ユーザーレベルの設定は~/.config/uv/uv.tomlにあり、システムレベルの設定はmacOSおよびLinuxの/etc/uv/uv.tomlにあります。

Important重要

User- and system-level configuration files cannot use the pyproject.toml format.ユーザーおよびシステムレベルの設定ファイルはpyproject.toml形式を使用できません。

If project-, user-, and system-level configuration files are found, the settings will be merged, with project-level configuration taking precedence over the user-level configuration, and user-level configuration taking precedence over the system-level configuration. (If multiple system-level configuration files are found, e.g., at both /etc/uv/uv.toml and $XDG_CONFIG_DIRS/uv/uv.toml, only the first-discovered file will be used, with XDG taking priority.)プロジェクト、ユーザー、およびシステムレベルの設定ファイルが見つかった場合、設定はマージされ、プロジェクトレベルの設定がユーザーレベルの設定よりも優先され、ユーザーレベルの設定がシステムレベルの設定よりも優先されます。(複数のシステムレベルの設定ファイルが見つかった場合、例えば/etc/uv/uv.toml$XDG_CONFIG_DIRS/uv/uv.tomlの両方に存在する場合、最初に発見されたファイルのみが使用され、XDGが優先されます。)

For example, if a string, number, or boolean is present in both the project- and user-level configuration tables, the project-level value will be used, and the user-level value will be ignored. If an array is present in both tables, the arrays will be concatenated, with the project-level settings appearing earlier in the merged array.例えば、文字列、数値、またはブール値がプロジェクトレベルとユーザーレベルの設定テーブルの両方に存在する場合、プロジェクトレベルの値が使用され、ユーザーレベルの値は無視されます。両方のテーブルに配列が存在する場合、配列は連結され、プロジェクトレベルの設定がマージされた配列の前に表示されます。

Settings provided via environment variables take precedence over persistent configuration, and settings provided via the command line take precedence over both.環境変数を介して提供された設定は永続的な設定よりも優先され、コマンドラインを介して提供された設定は両方の設定よりも優先されます。

uv accepts a --no-config command-line argument which, when provided, disables the discovery of any persistent configuration.uvは、提供された場合、永続的な設定の発見を無効にする--no-configコマンドライン引数を受け入れます。

uv also accepts a --config-file command-line argument, which accepts a path to a uv.toml to use as the configuration file. When provided, this file will be used in place of any discovered configuration files (e.g., user-level configuration will be ignored).uvはまた、uv.tomlへのパスを受け入れる--config-fileコマンドライン引数を受け入れます。このファイルが提供されると、発見された設定ファイルの代わりにこのファイルが使用されます(例:ユーザーレベルの設定は無視されます)。

Settings設定

See the settings reference for an enumeration of the available settings.設定リファレンスを参照して、利用可能な設定の列挙を確認してください。

.env.env

uv run can load environment variables from dotenv files (e.g., .env, .env.local, .env.development), powered by the dotenvy crate.uv runは、dotenvyクレートによって提供されるdotenvファイル(例:.env, .env.local, .env.development)から環境変数を読み込むことができます。

To load a .env file from a dedicated location, set the UV_ENV_FILE environment variable, or pass the --env-file flag to uv run.特定の場所から.envファイルを読み込むには、UV_ENV_FILE環境変数を設定するか、uv run--env-fileフラグを渡します。

For example, to load environment variables from a .env file in the current working directory:例えば、現在の作業ディレクトリにある.envファイルから環境変数を読み込むには:

$ echo "MY_VAR='Hello, world!'" > .env
$ uv run --env-file .env -- python -c 'import os; print(os.getenv("MY_VAR"))'
Hello, world!

The --env-file flag can be provided multiple times, with subsequent files overriding values defined in previous files. To provide multiple files via the UV_ENV_FILE environment variable, separate the paths with a space (e.g., UV_ENV_FILE="/path/to/file1 /path/to/file2").--env-fileフラグは複数回提供でき、後続のファイルは前のファイルで定義された値を上書きします。UV_ENV_FILE環境変数を介して複数のファイルを提供するには、パスをスペースで区切ります(例:UV_ENV_FILE="/path/to/file1 /path/to/file2")。

To disable dotenv loading (e.g., to override UV_ENV_FILE or the --env-file command-line argument), set the UV_NO_ENV_FILE environment variable to 1, or pass the--no-env-file flag to uv run.dotenvの読み込みを無効にするには(例:UV_ENV_FILEまたは--env-fileコマンドライン引数を上書きするため)、UV_NO_ENV_FILE環境変数を1に設定するか、--no-env-fileフラグをuv runに渡します。

If the same variable is defined in the environment and in a .env file, the value from the environment will take precedence.環境と.envファイルの両方で同じ変数が定義されている場合、環境からの値が優先されます。

Configuring the pip interfacepipインターフェースの設定

A dedicated [tool.uv.pip] section is provided for configuring just the uv pip command line interface. Settings in this section will not apply to uv commands outside the uv pip namespace. However, many of the settings in this section have corollaries in the top-level namespace which do apply to the uv pip interface unless they are overridden by a value in the uv.pip section.[tool.uv.pip]セクションは、uv pipコマンドラインインターフェースをのみ設定するために提供されています。このセクションの設定は、uv pip名前空間外のuvコマンドには適用されません。ただし、このセクションの多くの設定は、uv pipインターフェースに適用されるトップレベル名前空間に相当するものがありますが、それらはuv.pipセクションの値によって上書きされない限り適用されます。

The uv.pip settings are designed to adhere closely to pip's interface and are declared separately to retain compatibility while allowing the global settings to use alternate designs (e.g., --no-build).uv.pip設定は、pipのインターフェースに密接に従うように設計されており、互換性を保ちながらグローバル設定が代替設計(例:--no-build)を使用できるように別々に宣言されています。

As an example, setting the index-url under [tool.uv.pip], as in the following pyproject.toml, would only affect the uv pip subcommands (e.g., uv pip install, but not uv sync, uv lock, or uv run):例として、次のpyproject.tomlのように[tool.uv.pip]の下にindex-urlを設定すると、uv pipサブコマンド(例:uv pip install)にのみ影響し、uv syncuv lock、またはuv runには影響しません。

pyproject.toml
[tool.uv.pip]
index-url = "https://test.pypi.org/simple"