| 1 /*! |
1 /*! |
| 2 Build script for `pointsource_pde` |
2 Build script for `pointsource_pde` |
| 3 */ |
3 */ |
| |
4 |
| |
5 #![feature(path_is_empty)] |
| 4 |
6 |
| 5 //use pyo3::{prepare_freethreaded_python, types::PyModule, PyErr, Python}; |
7 //use pyo3::{prepare_freethreaded_python, types::PyModule, PyErr, Python}; |
| 6 use conda_build::python_config; |
8 use conda_build::python_config; |
| 7 use std::env::split_paths; |
9 use std::env::split_paths; |
| 8 use std::fs::File; |
10 use std::fs::File; |
| 36 // PyModule::import(py, m)?; |
38 // PyModule::import(py, m)?; |
| 37 // } |
39 // } |
| 38 // Ok::<_, PyErr>(()) |
40 // Ok::<_, PyErr>(()) |
| 39 // })?; |
41 // })?; |
| 40 |
42 |
| 41 let (pyc_e, py_is_conda) = python_config(); |
43 let (pyc_e, _prefix_override, _py_type) = python_config(); |
| 42 let py_path = pyc_e.and_then(|pyc| pyc.exec_prefix_path())?; |
44 let py_path = pyc_e.and_then(|pyc| pyc.exec_prefix_path())?; |
| 43 let py_exec = py_path.join("bin").join("python3"); |
45 let py_exec = py_path.join("bin").join("python3"); |
| 44 let import_check_code = REQUIRED_PYTHON_MODULES |
46 let import_check_code = REQUIRED_PYTHON_MODULES |
| 45 .map(|m| format!("import {}\n", m)) |
47 .map(|m| format!("import {}\n", m)) |
| 46 .concat(); |
48 .concat(); |
| 47 let res = Command::new(&py_exec) |
49 let res = Command::new(&py_exec) |
| 48 .args(["-c", import_check_code.as_ref()]) |
50 .args(["-c", import_check_code.as_ref()]) |
| 49 .status()?; |
51 .status()?; |
| 50 if !res.success() { |
52 if !res.success() { |
| 51 return Err(std::io::Error::other(format!( |
53 return Err(std::io::Error::other(format!( |
| 52 "Failed to load required Python modules (python execuitable {}{})", |
54 "Failed to load required Python modules (python execuitable {})", |
| 53 py_exec.display(), |
55 py_exec.display(), |
| 54 if py_is_conda { " from Conda" } else { "" } |
|
| 55 ))); |
56 ))); |
| 56 } |
57 } |
| 57 |
58 |
| 58 // Set up local-to-crate paths |
59 // Set up local-to-crate paths |
| 59 let cc_mod_name = "dolfinx_access"; |
60 let cc_mod_name = "dolfinx_access"; |
| 128 } |
129 } |
| 129 |
130 |
| 130 fn add_dep_ldflags(dep: &str) { |
131 fn add_dep_ldflags(dep: &str) { |
| 131 if let Some(ldflags) = std::env::var_os(&dep) { |
132 if let Some(ldflags) = std::env::var_os(&dep) { |
| 132 for lp in split_paths(&ldflags) { |
133 for lp in split_paths(&ldflags) { |
| 133 println!("cargo:rustc-link-arg=-Wl,{}", lp.display()); |
134 if !lp.is_empty() { |
| |
135 println!("cargo:rustc-link-arg=-Wl,{}", lp.display()); |
| |
136 } |
| 134 } |
137 } |
| 135 } else { |
138 } else { |
| 136 panic!("{dep} unset."); |
139 panic!("{dep} unset."); |
| 137 } |
140 } |
| 138 } |
141 } |