Fix bug where --no-binary :all: prevented build of editable packages (#2393)

Closes https://github.com/astral-sh/uv/issues/2343
This commit is contained in:
Zanie Blue 2024-03-12 18:21:40 -05:00 committed by GitHub
parent 7220894ffb
commit 00ec99399a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 1 deletions

View file

@ -280,7 +280,10 @@ impl<'a> BuildContext for BuildDispatch<'a> {
build_kind: BuildKind,
) -> Result<SourceBuild> {
match self.no_build {
NoBuild::All => bail!("Building source distributions is disabled"),
NoBuild::All => debug_assert!(
matches!(build_kind, BuildKind::Editable),
"Only editable builds are exempt from 'no build' checks"
),
NoBuild::None => {}
NoBuild::Packages(packages) => {
if let Some(dist) = dist {

View file

@ -696,6 +696,45 @@ fn install_editable_and_registry() -> Result<()> {
Ok(())
}
#[test]
fn install_editable_no_binary() -> Result<()> {
let context = TestContext::new("3.12");
let current_dir = std::env::current_dir()?;
let workspace_dir = regex::escape(
Url::from_directory_path(current_dir.join("..").join("..").canonicalize()?)
.unwrap()
.as_str(),
);
let filters = [(workspace_dir.as_str(), "file://[WORKSPACE_DIR]/")]
.into_iter()
.chain(INSTA_FILTERS.to_vec())
.collect::<Vec<_>>();
// Install the editable package with no-binary enabled
uv_snapshot!(filters, command(&context)
.arg("-e")
.arg("../../scripts/editable-installs/black_editable")
.arg("--no-binary")
.arg(":all:")
.current_dir(&current_dir)
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Built 1 editable in [TIME]
Resolved 1 package in [TIME]
Installed 1 package in [TIME]
+ black==0.1.0 (from file://[WORKSPACE_DIR]/scripts/editable-installs/black_editable)
"###
);
Ok(())
}
/// Install a source distribution that uses the `flit` build system, along with `flit`
/// at the top-level, along with `--reinstall` to force a re-download after resolution, to ensure
/// that the `flit` install and the source distribution build don't conflict.