Skip to content

Commit

Permalink
Install cffi and uv on demand in test_develop (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
messense authored Apr 16, 2024
1 parent ccbd31a commit e65db94
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
40 changes: 21 additions & 19 deletions tests/common/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,34 @@ pub fn test_develop(
// Ensure the test doesn't wrongly pass
check_installed(package, &python).unwrap_err();

let mut cmd = Command::new(&python);
cmd.args([
"-m",
"pip",
"install",
"--disable-pip-version-check",
"cffi",
]);
let uv = matches!(test_backend, TestInstallBackend::Uv);
let mut pip_packages = Vec::new();
if unique_name.contains("cffi") {
pip_packages.push("cffi");
}
if cfg!(any(
target_os = "linux",
target_os = "macos",
target_os = "windows"
)) {
cmd.arg("uv");
)) && uv
{
pip_packages.push("uv");
}
let output = cmd.output()?;
if !output.status.success() {
panic!(
"Failed to install cffi: {}\n---stdout:\n{}---stderr:\n{}",
output.status,
str::from_utf8(&output.stdout)?,
str::from_utf8(&output.stderr)?
);
if !pip_packages.is_empty() {
let mut cmd = Command::new(&python);
cmd.args(["-m", "pip", "install", "--disable-pip-version-check"])
.args(pip_packages);
let output = cmd.output()?;
if !output.status.success() {
panic!(
"Failed to install cffi: {}\n---stdout:\n{}---stderr:\n{}",
output.status,
str::from_utf8(&output.stdout)?,
str::from_utf8(&output.stderr)?
);
}
}

let uv = matches!(test_backend, TestInstallBackend::Uv);
let manifest_file = package.join("Cargo.toml");
let develop_options = DevelopOptions {
bindings,
Expand Down
1 change: 1 addition & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod errors;
pub mod integration;
pub mod other;

#[derive(Clone, Copy, PartialEq, Eq)]
pub enum TestInstallBackend {
Pip,
Uv,
Expand Down

0 comments on commit e65db94

Please sign in to comment.