Skip to content
Closed
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
284 changes: 262 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
95 changes: 94 additions & 1 deletion Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ petgraph = { version = "0.7.1" }
proc-macro2 = { version = "1.0.86" }
procfs = { version = "0.17.0", default-features = false, features = ["flate2"] }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "b70cf707aa43f21b32f3a61b8a0889b15032d5c4" }
pyo3 = { version = "0.23.5" }
quote = { version = "1.0.37" }
rayon = { version = "1.10.0" }
reflink-copy = { version = "0.1.19" }
Expand Down Expand Up @@ -278,6 +279,14 @@ inherits = "dev"
debug = 0
strip = "debuginfo"

# Profile to build a minimally sized binary for uv-build
[profile.minimal-size]
inherits = "release"
opt-level = "z"
# This will still show a panic message, we only skip the unwind
panic = "abort"
codegen-units = 1

# The profile that 'cargo dist' will build with.
[profile.dist]
inherits = "release"
Expand Down
9 changes: 5 additions & 4 deletions crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod metadata;
mod serde_verbatim;
mod source_dist;
mod wheel;

Expand Down Expand Up @@ -394,8 +395,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 @@ -462,8 +463,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
52 changes: 28 additions & 24 deletions crates/uv-build-backend/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use uv_pep508::{
};
use uv_pypi_types::{Metadata23, VerbatimParsedUrl};

use crate::serde_verbatim::SerdeVerbatim;
use crate::Error;

/// By default, we ignore generated python files.
Expand Down Expand Up @@ -161,14 +162,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 +190,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 +222,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.verbatim()
));
}

Expand Down Expand Up @@ -768,7 +772,7 @@ pub(crate) enum Contact {
#[serde(rename_all = "kebab-case")]
struct BuildSystem {
/// PEP 508 dependencies required to execute the build system.
requires: Vec<Requirement<VerbatimParsedUrl>>,
requires: Vec<SerdeVerbatim<Requirement<VerbatimParsedUrl>>>,
/// A string naming a Python object that will be used to perform the build.
build_backend: Option<String>,
/// <https://peps.python.org/pep-0517/#in-tree-build-backends>
Expand Down Expand Up @@ -940,8 +944,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 +1027,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 +1154,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 +1235,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 +1253,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 +1272,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 +1289,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
Loading
Loading