mirror of https://github.com/astral-sh/uv
Stabilize the uv build backend (#14311)
The uv build backend has gone through some feedback cycles, we expect no more major configuration changes, and we're ready to take the next step: The uv build backend in stable. This PR stabilizes: * Using `uv_build` as build backend * The documentation of the uv build backend * The direct build fast path, where uv doesn't use PEP 517 if you're using `uv_build` in a compatible version. * `uv build --list`, which is limited to `uv_build`. It does not: * Make `uv_build` the default on `uv init` * Make `--package` the default on `uv init`
This commit is contained in:
parent
5f2857a1c7
commit
71b5ba13d7
|
|
@ -4,10 +4,6 @@ use uv_macros::OptionsMetadata;
|
||||||
|
|
||||||
/// Settings for the uv build backend (`uv_build`).
|
/// Settings for the uv build backend (`uv_build`).
|
||||||
///
|
///
|
||||||
/// !!! note
|
|
||||||
///
|
|
||||||
/// The uv build backend is currently in preview and may change in any future release.
|
|
||||||
///
|
|
||||||
/// Note that those settings only apply when using the `uv_build` backend, other build backends
|
/// Note that those settings only apply when using the `uv_build` backend, other build backends
|
||||||
/// (such as hatchling) have their own configuration.
|
/// (such as hatchling) have their own configuration.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -453,12 +453,6 @@ impl BuildContext for BuildDispatch<'_> {
|
||||||
build_kind: BuildKind,
|
build_kind: BuildKind,
|
||||||
version_id: Option<&'data str>,
|
version_id: Option<&'data str>,
|
||||||
) -> Result<Option<DistFilename>, BuildDispatchError> {
|
) -> Result<Option<DistFilename>, BuildDispatchError> {
|
||||||
// Direct builds are a preview feature with the uv build backend.
|
|
||||||
if self.preview.is_disabled() {
|
|
||||||
trace!("Preview is disabled, not checking for direct build");
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let source_tree = if let Some(subdir) = subdirectory {
|
let source_tree = if let Some(subdir) = subdirectory {
|
||||||
source.join(subdir)
|
source.join(subdir)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -187,15 +187,6 @@ async fn build_impl(
|
||||||
printer: Printer,
|
printer: Printer,
|
||||||
preview: PreviewMode,
|
preview: PreviewMode,
|
||||||
) -> Result<BuildResult> {
|
) -> Result<BuildResult> {
|
||||||
if list && preview.is_disabled() {
|
|
||||||
// We need the direct build for list and that is preview only.
|
|
||||||
writeln!(
|
|
||||||
printer.stderr(),
|
|
||||||
"The `--list` option is only available in preview mode; add the `--preview` flag to use `--list`"
|
|
||||||
)?;
|
|
||||||
return Ok(BuildResult::Failure);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the resolver settings.
|
// Extract the resolver settings.
|
||||||
let ResolverSettings {
|
let ResolverSettings {
|
||||||
index_locations,
|
index_locations,
|
||||||
|
|
@ -605,10 +596,7 @@ async fn build_package(
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildAction::List
|
BuildAction::List
|
||||||
} else if preview.is_enabled()
|
} else if !force_pep517 && check_direct_build(source.path(), source.path().user_display()) {
|
||||||
&& !force_pep517
|
|
||||||
&& check_direct_build(source.path(), source.path().user_display())
|
|
||||||
{
|
|
||||||
BuildAction::DirectBuild
|
BuildAction::DirectBuild
|
||||||
} else {
|
} else {
|
||||||
BuildAction::Pep517
|
BuildAction::Pep517
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,6 @@ fn preserve_executable_bit() -> Result<()> {
|
||||||
.init()
|
.init()
|
||||||
.arg("--build-backend")
|
.arg("--build-backend")
|
||||||
.arg("uv")
|
.arg("uv")
|
||||||
.arg("--preview")
|
|
||||||
.arg(&project_dir)
|
.arg(&project_dir)
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
@ -316,8 +315,7 @@ fn rename_module() -> Result<()> {
|
||||||
uv_snapshot!(context
|
uv_snapshot!(context
|
||||||
.build_backend()
|
.build_backend()
|
||||||
.arg("build-wheel")
|
.arg("build-wheel")
|
||||||
.arg(temp_dir.path())
|
.arg(temp_dir.path()), @r###"
|
||||||
.env("UV_PREVIEW", "1"), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -391,8 +389,7 @@ fn rename_module_editable_build() -> Result<()> {
|
||||||
uv_snapshot!(context
|
uv_snapshot!(context
|
||||||
.build_backend()
|
.build_backend()
|
||||||
.arg("build-editable")
|
.arg("build-editable")
|
||||||
.arg(temp_dir.path())
|
.arg(temp_dir.path()), @r###"
|
||||||
.env("UV_PREVIEW", "1"), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -568,8 +565,7 @@ fn build_sdist_with_long_path() -> Result<()> {
|
||||||
uv_snapshot!(context
|
uv_snapshot!(context
|
||||||
.build_backend()
|
.build_backend()
|
||||||
.arg("build-sdist")
|
.arg("build-sdist")
|
||||||
.arg(temp_dir.path())
|
.arg(temp_dir.path()), @r###"
|
||||||
.env("UV_PREVIEW", "1"), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -602,8 +598,7 @@ fn sdist_error_without_module() -> Result<()> {
|
||||||
uv_snapshot!(context
|
uv_snapshot!(context
|
||||||
.build_backend()
|
.build_backend()
|
||||||
.arg("build-sdist")
|
.arg("build-sdist")
|
||||||
.arg(temp_dir.path())
|
.arg(temp_dir.path()), @r"
|
||||||
.env("UV_PREVIEW", "1"), @r"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 2
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -617,8 +612,7 @@ fn sdist_error_without_module() -> Result<()> {
|
||||||
uv_snapshot!(context
|
uv_snapshot!(context
|
||||||
.build_backend()
|
.build_backend()
|
||||||
.arg("build-sdist")
|
.arg("build-sdist")
|
||||||
.arg(temp_dir.path())
|
.arg(temp_dir.path()), @r"
|
||||||
.env("UV_PREVIEW", "1"), @r"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 2
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -682,7 +676,6 @@ fn complex_namespace_packages() -> Result<()> {
|
||||||
|
|
||||||
context
|
context
|
||||||
.build()
|
.build()
|
||||||
.arg("--preview")
|
|
||||||
.arg(project.path())
|
.arg(project.path())
|
||||||
.arg("--out-dir")
|
.arg("--out-dir")
|
||||||
.arg(dist.path())
|
.arg(dist.path())
|
||||||
|
|
@ -731,7 +724,6 @@ fn complex_namespace_packages() -> Result<()> {
|
||||||
context.filters(),
|
context.filters(),
|
||||||
context
|
context
|
||||||
.pip_install()
|
.pip_install()
|
||||||
.arg("--preview")
|
|
||||||
.arg("-e")
|
.arg("-e")
|
||||||
.arg("complex-project-part_a")
|
.arg("complex-project-part_a")
|
||||||
.arg("-e")
|
.arg("-e")
|
||||||
|
|
@ -778,7 +770,6 @@ fn symlinked_file() -> Result<()> {
|
||||||
let project = context.temp_dir.child("project");
|
let project = context.temp_dir.child("project");
|
||||||
context
|
context
|
||||||
.init()
|
.init()
|
||||||
.arg("--preview")
|
|
||||||
.arg("--build-backend")
|
.arg("--build-backend")
|
||||||
.arg("uv")
|
.arg("uv")
|
||||||
.arg(project.path())
|
.arg(project.path())
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
|
|
||||||
The uv build backend is currently in preview and may change without warning.
|
Currently, the default build backend for `uv init` is
|
||||||
|
[hatchling](https://pypi.org/project/hatchling/). This will change to `uv` in a future version.
|
||||||
When preview mode is not enabled, uv uses [hatchling](https://pypi.org/project/hatchling/) as the default build backend.
|
|
||||||
|
|
||||||
A build backend transforms a source tree (i.e., a directory) into a source distribution or a wheel.
|
A build backend transforms a source tree (i.e., a directory) into a source distribution or a wheel.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,10 +396,6 @@ pydantic = { path = "/path/to/pydantic", editable = true }
|
||||||
|
|
||||||
Settings for the uv build backend (`uv_build`).
|
Settings for the uv build backend (`uv_build`).
|
||||||
|
|
||||||
!!! note
|
|
||||||
|
|
||||||
The uv build backend is currently in preview and may change in any future release.
|
|
||||||
|
|
||||||
Note that those settings only apply when using the `uv_build` backend, other build backends
|
Note that those settings only apply when using the `uv_build` backend, other build backends
|
||||||
(such as hatchling) have their own configuration.
|
(such as hatchling) have their own configuration.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -644,7 +644,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"BuildBackendSettings": {
|
"BuildBackendSettings": {
|
||||||
"description": "Settings for the uv build backend (`uv_build`).\n\n!!! note\n\n The uv build backend is currently in preview and may change in any future release.\n\nNote that those settings only apply when using the `uv_build` backend, other build backends\n(such as hatchling) have their own configuration.\n\nAll options that accept globs use the portable glob patterns from\n[PEP 639](https://packaging.python.org/en/latest/specifications/glob-patterns/).",
|
"description": "Settings for the uv build backend (`uv_build`).\n\nNote that those settings only apply when using the `uv_build` backend, other build backends\n(such as hatchling) have their own configuration.\n\nAll options that accept globs use the portable glob patterns from\n[PEP 639](https://packaging.python.org/en/latest/specifications/glob-patterns/).",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"data": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue