mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Add a test for --force-pep517
(#14310)
There was previously a gap in the test coverage in ensuring that `--force-pep517` was respected.
This commit is contained in:
parent
85c0fc963b
commit
39cdfe9981
1 changed files with 64 additions and 1 deletions
|
@ -133,7 +133,7 @@ fn build_sdist() -> Result<()> {
|
||||||
let filters = context
|
let filters = context
|
||||||
.filters()
|
.filters()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain([(r"exit code: 1", "exit status: 1"), (r"\\\.", "")])
|
.chain([(r"exit code: ", "exit status: "), (r"\\\.", "")])
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let project = context.temp_dir.child("project");
|
let project = context.temp_dir.child("project");
|
||||||
|
@ -1981,3 +1981,66 @@ fn build_with_nonnormalized_name() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check that `--force-pep517` is respected.
|
||||||
|
///
|
||||||
|
/// The error messages for a broken project are different for direct builds vs. PEP 517.
|
||||||
|
#[test]
|
||||||
|
fn force_pep517() -> Result<()> {
|
||||||
|
// We need to use a real `uv_build` package.
|
||||||
|
let context = TestContext::new("3.12").with_exclude_newer("2025-05-27T00:00:00Z");
|
||||||
|
|
||||||
|
context
|
||||||
|
.init()
|
||||||
|
.arg("--build-backend")
|
||||||
|
.arg("uv")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||||
|
pyproject_toml.write_str(indoc! {r#"
|
||||||
|
[project]
|
||||||
|
name = "project"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[tool.uv.build-backend]
|
||||||
|
module-name = "does_not_exist"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["uv_build>=0.5.15,<10000"]
|
||||||
|
build-backend = "uv_build"
|
||||||
|
"#})?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), context.build().env("RUST_BACKTRACE", "0"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Building source distribution (uv build backend)...
|
||||||
|
× Failed to build `[TEMP_DIR]/`
|
||||||
|
╰─▶ Expected a Python module at: `src/does_not_exist/__init__.py`
|
||||||
|
");
|
||||||
|
|
||||||
|
let filters = context
|
||||||
|
.filters()
|
||||||
|
.into_iter()
|
||||||
|
.chain([(r"exit code: 1", "exit status: 1")])
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
uv_snapshot!(filters, context.build().arg("--force-pep517").env("RUST_BACKTRACE", "0"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Building source distribution...
|
||||||
|
Error: Missing module directory for `does_not_exist` in `src`. Found: `temp`
|
||||||
|
× Failed to build `[TEMP_DIR]/`
|
||||||
|
├─▶ The build backend returned an error
|
||||||
|
╰─▶ Call to `uv_build.build_sdist` failed (exit status: 1)
|
||||||
|
hint: This usually indicates a problem with the package or the build environment.
|
||||||
|
");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue