-
-
Notifications
You must be signed in to change notification settings - Fork 296
/
Copy pathdevelop.rs
64 lines (58 loc) · 1.85 KB
/
develop.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::common::{check_installed, create_conda_env, create_virtualenv, maybe_mock_cargo};
use anyhow::Result;
use maturin::{develop, CargoOptions, DevelopOptions};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;
/// Creates a virtualenv and activates it, checks that the package isn't installed, uses
/// "maturin develop" to install it and checks it is working
pub fn test_develop(
package: impl AsRef<Path>,
bindings: Option<String>,
unique_name: &str,
conda: bool,
) -> Result<()> {
maybe_mock_cargo();
let package = package.as_ref();
let (venv_dir, python) = if conda {
create_conda_env(&format!("maturin-{unique_name}"), 3, 10)?
} else {
create_virtualenv(unique_name, None)?
};
// Ensure the test doesn't wrongly pass
check_installed(package, &python).unwrap_err();
let output = Command::new(&python)
.args([
"-m",
"pip",
"install",
"--disable-pip-version-check",
"cffi",
])
.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 manifest_file = package.join("Cargo.toml");
let develop_options = DevelopOptions {
bindings,
release: false,
strip: false,
extras: Vec::new(),
skip_install: false,
cargo_options: CargoOptions {
manifest_path: Some(manifest_file),
quiet: true,
target_dir: Some(PathBuf::from(format!("test-crates/targets/{unique_name}"))),
..Default::default()
},
};
develop(develop_options, &venv_dir)?;
check_installed(package, &python)?;
Ok(())
}