Add `UV_INIT_BUILD_BACKEND` (#14821)

Closes https://github.com/astral-sh/uv/issues/14820
This commit is contained in:
Zanie Blue 2025-07-22 14:10:08 -05:00 committed by GitHub
parent 27ade0676f
commit 8289e38e8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 2 deletions

View File

@ -2891,7 +2891,7 @@ pub struct InitArgs {
/// Initialize a build-backend of choice for the project. /// Initialize a build-backend of choice for the project.
/// ///
/// Implicitly sets `--package`. /// Implicitly sets `--package`.
#[arg(long, value_enum, conflicts_with_all=["script", "no_package"])] #[arg(long, value_enum, conflicts_with_all=["script", "no_package"], env = EnvVars::UV_INIT_BUILD_BACKEND)]
pub build_backend: Option<ProjectBuildBackend>, pub build_backend: Option<ProjectBuildBackend>,
/// Invalid option name for build backend. /// Invalid option name for build backend.

View File

@ -257,6 +257,10 @@ impl EnvVars {
/// Specifies the "bin" directory for installing tool executables. /// Specifies the "bin" directory for installing tool executables.
pub const UV_TOOL_BIN_DIR: &'static str = "UV_TOOL_BIN_DIR"; pub const UV_TOOL_BIN_DIR: &'static str = "UV_TOOL_BIN_DIR";
/// Equivalent to the `--build-backend` argument for `uv init`. Determines the default backend
/// to use when creating a new project.
pub const UV_INIT_BUILD_BACKEND: &'static str = "UV_INIT_BUILD_BACKEND";
/// Specifies the path to the directory to use for a project virtual environment. /// Specifies the path to the directory to use for a project virtual environment.
/// ///
/// See the [project documentation](../concepts/projects/config.md#project-environment-path) /// See the [project documentation](../concepts/projects/config.md#project-environment-path)

View File

@ -302,7 +302,7 @@ uv init [OPTIONS] [PATH]
<p>Disables creating extra files like <code>README.md</code>, the <code>src/</code> tree, <code>.python-version</code> files, etc.</p> <p>Disables creating extra files like <code>README.md</code>, the <code>src/</code> tree, <code>.python-version</code> files, etc.</p>
</dd><dt id="uv-init--build-backend"><a href="#uv-init--build-backend"><code>--build-backend</code></a> <i>build-backend</i></dt><dd><p>Initialize a build-backend of choice for the project.</p> </dd><dt id="uv-init--build-backend"><a href="#uv-init--build-backend"><code>--build-backend</code></a> <i>build-backend</i></dt><dd><p>Initialize a build-backend of choice for the project.</p>
<p>Implicitly sets <code>--package</code>.</p> <p>Implicitly sets <code>--package</code>.</p>
<p>Possible values:</p> <p>May also be set with the <code>UV_INIT_BUILD_BACKEND</code> environment variable.</p><p>Possible values:</p>
<ul> <ul>
<li><code>hatch</code>: Use <a href="https://pypi.org/project/hatchling">hatchling</a> as the project build backend</li> <li><code>hatch</code>: Use <a href="https://pypi.org/project/hatchling">hatchling</a> as the project build backend</li>
<li><code>flit</code>: Use <a href="https://pypi.org/project/flit-core">flit-core</a> as the project build backend</li> <li><code>flit</code>: Use <a href="https://pypi.org/project/flit-core">flit-core</a> as the project build backend</li>

View File

@ -147,6 +147,11 @@ Provides the HTTP Basic authentication username for a named index.
The `name` parameter is the name of the index. For example, given an index named `foo`, The `name` parameter is the name of the index. For example, given an index named `foo`,
the environment variable key would be `UV_INDEX_FOO_USERNAME`. the environment variable key would be `UV_INDEX_FOO_USERNAME`.
### `UV_INIT_BUILD_BACKEND`
Equivalent to the `--build-backend` argument for `uv init`. Determines the default backend
to use when creating a new project.
### `UV_INSECURE_HOST` ### `UV_INSECURE_HOST`
Equivalent to the `--allow-insecure-host` argument. Equivalent to the `--allow-insecure-host` argument.