Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A minimal build backend for uv: uv_build #11446

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 275 additions & 22 deletions .github/workflows/build-binaries.yml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: "Check uv_build dependencies"
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check bans
manifest-path: crates/uv-build/Cargo.toml
- name: "Install Rust toolchain"
run: rustup component add clippy
- name: "Clippy"
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
type: string

jobs:
pypi-publish:
name: Upload to PyPI
pypi-publish-uv:
name: Upload uv to PyPI
runs-on: ubuntu-latest
environment:
name: release
Expand All @@ -25,8 +25,27 @@ jobs:
uses: astral-sh/setup-uv@v5
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheels
pattern: wheels_uv-*
path: wheels_uv
merge-multiple: true
- name: Publish to PyPi
run: uv publish -v wheels/*
run: uv publish -v wheels_uv/*

pypi-publish-uv-build:
name: Upload uv-build to PyPI
runs-on: ubuntu-latest
environment:
name: release
permissions:
# For PyPI's trusted publishing.
id-token: write
steps:
- name: "Install uv"
uses: astral-sh/setup-uv@v5
- uses: actions/download-artifact@v4
with:
pattern: wheels_uv_build-*
path: wheels_uv_build
merge-multiple: true
- name: Publish to PyPi
run: uv publish -v wheels_uv_build/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ __pycache__
*.so
*.pyd
*.dll
/dist
/crates/uv-build/dist

# Profiling
flamegraph.svg
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ inherits = "dev"
debug = 0
strip = "debuginfo"

# Profile for uv-build
[profile.minimal-size]
inherits = "release"
opt-level = "z"
panic = "abort"

# The profile that 'cargo dist' will build with.
[profile.dist]
inherits = "release"
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ mod tests {
license = { file = "license.txt" }
[build-system]
requires = ["uv>=0.5.15,<0.6"]
build-backend = "uv"
requires = ["uv_build>=0.5.15,<0.6"]
build-backend = "uv_build"
"#
},
)
Expand Down Expand Up @@ -471,8 +471,8 @@ mod tests {
version = "1.0.0"
[build-system]
requires = ["uv>=0.5.15,<0.6"]
build-backend = "uv"
requires = ["uv_build>=0.5.15,<0.6"]
build-backend = "uv_build"
"#
},
)
Expand Down
49 changes: 26 additions & 23 deletions crates/uv-build-backend/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ impl PyProjectToml {
///
/// ```toml
/// [build-system]
/// requires = ["uv>=0.4.15,<5"]
/// build-backend = "uv"
/// requires = ["uv_build>=0.4.15,<5"]
/// build-backend = "uv_build"
/// ```
pub fn check_build_system(&self, uv_version: &str) -> Vec<String> {
let mut warnings = Vec::new();
if self.build_system.build_backend.as_deref() != Some("uv") {
if self.build_system.build_backend.as_deref() != Some("uv_build") {
warnings.push(format!(
r#"The value for `build_system.build-backend` should be `"uv"`, not `"{}"`"#,
r#"The value for `build_system.build-backend` should be `"uv_build"`, not `"{}"`"#,
self.build_system.build_backend.clone().unwrap_or_default()
));
}
Expand All @@ -189,7 +189,7 @@ impl PyProjectToml {
warnings.push(expected());
return warnings;
};
if uv_requirement.name.as_str() != "uv" {
if uv_requirement.name.as_str() != "uv-build" {
warnings.push(expected());
return warnings;
}
Expand Down Expand Up @@ -221,10 +221,13 @@ impl PyProjectToml {

if !bounded {
warnings.push(format!(
"`build_system.requires = [\"{uv_requirement}\"]` is missing an \
upper bound on the uv version such as `<{next_breaking}`. \
Without bounding the uv version, the source distribution will break \
when a future, breaking version of uv is released.",
"`build_system.requires = [\"{}\"]` is missing an \
upper bound on the uv_build version such as `<{next_breaking}`. \
Without bounding the uv_build version, the source distribution will break \
when a future, breaking version of uv_build is released.",
// Use an underscore consistently, to avoid confusing users between a package name with dash and a
// module name with underscore
uv_requirement.to_string().replace("uv-build", "uv_build")
));
}

Expand Down Expand Up @@ -940,8 +943,8 @@ mod tests {
{payload}

[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv_build>=0.4.15,<5"]
build-backend = "uv_build"
"#
}
}
Expand Down Expand Up @@ -1023,8 +1026,8 @@ mod tests {
foo-bar = "foo:bar"

[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv_build>=0.4.15,<5"]
build-backend = "uv_build"
"#
};

Expand Down Expand Up @@ -1150,8 +1153,8 @@ mod tests {
foo-bar = "foo:bar"

[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv_build>=0.4.15,<5"]
build-backend = "uv_build"
"#
};

Expand Down Expand Up @@ -1231,13 +1234,13 @@ mod tests {
version = "0.1.0"

[build-system]
requires = ["uv"]
build-backend = "uv"
requires = ["uv_build"]
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
pyproject_toml.check_build_system("0.4.15+test").join("\n"),
@r###"`build_system.requires = ["uv"]` is missing an upper bound on the uv version such as `<0.5`. Without bounding the uv version, the source distribution will break when a future, breaking version of uv is released."###
@r###"`build_system.requires = ["uv_build"]` is missing an upper bound on the uv_build version such as `<0.5`. Without bounding the uv_build version, the source distribution will break when a future, breaking version of uv_build is released."###
);
}

Expand All @@ -1249,8 +1252,8 @@ mod tests {
version = "0.1.0"

[build-system]
requires = ["uv>=0.4.15,<5", "wheel"]
build-backend = "uv"
requires = ["uv_build>=0.4.15,<5", "wheel"]
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
Expand All @@ -1268,7 +1271,7 @@ mod tests {

[build-system]
requires = ["setuptools"]
build-backend = "uv"
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
Expand All @@ -1285,13 +1288,13 @@ mod tests {
version = "0.1.0"

[build-system]
requires = ["uv>=0.4.15,<5"]
requires = ["uv_build>=0.4.15,<5"]
build-backend = "setuptools"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
pyproject_toml.check_build_system("0.4.15+test").join("\n"),
@r###"The value for `build_system.build-backend` should be `"uv"`, not `"setuptools"`"###
@r###"The value for `build_system.build-backend` should be `"uv_build"`, not `"setuptools"`"###
);
}

Expand Down
19 changes: 19 additions & 0 deletions crates/uv-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "uv-build"
version = "0.5.31"
edition.workspace = true
rust-version.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true

[dependencies]
uv-build-backend = { workspace = true }
uv-version = { workspace = true }

anyhow = { workspace = true }

[lints]
workspace = true
Loading
Loading