-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the path of Matplotlib to the link search (for Anaconda)
- Loading branch information
Showing
3 changed files
with
94 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::{env, | ||
fs::File, | ||
io::Write, | ||
path::Path, | ||
process::Command, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let outdir = env::var("OUT_DIR") | ||
.expect("The OUT_DIR variable must be defined during compilation"); | ||
let py = Path::new(&outdir).join("matplotlib_location.py"); | ||
let mut fh = File::create(&py)?; | ||
writeln!(fh, "import matplotlib\nprint(matplotlib.__file__)")?; | ||
drop(fh); | ||
|
||
let plt_path = Command::new("python3") | ||
.arg(py) | ||
.output() | ||
.expect("`python3` or package `matplotlib` not found.") | ||
.stdout; | ||
let plt_path = String::from_utf8_lossy(&plt_path); | ||
let plt_path = Path::new(plt_path.as_ref()); | ||
if let Some(d) = plt_path.parent() { | ||
let d = d.to_str().unwrap(); | ||
println!("cargo:warning={d}"); | ||
println!("cargo:rustc-env=ANACONDA_DIR={d}"); | ||
} | ||
|
||
// if let Ok(mut conda) = env::var("CONDA") { | ||
// conda += "/lib"; | ||
// println!("cargo:rustc-env=ANACONDA_DIR={conda}"); | ||
// } | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters