| 15 "implicit.cpp", |
15 "implicit.cpp", |
| 16 ]; |
16 ]; |
| 17 |
17 |
| 18 fn main() -> Result<(), anyhow::Error> { |
18 fn main() -> Result<(), anyhow::Error> { |
| 19 // Need to build it |
19 // Need to build it |
| 20 let (pyc_e, py_conda) = python_config(); |
20 let (pyc_e, prefix_override, py_type) = python_config(); |
| 21 |
21 |
| 22 // This is very clumsy due to PythonConfig::Error not supporting |
22 // This is very clumsy due to PythonConfig::Error not supporting |
| 23 // conversion into std::error::Error, just std::io::Error. |
23 // conversion into std::error::Error, just std::io::Error. |
| 24 let (pyc, mut includes, _py_ldflags) = pyc_e |
24 let (pyc, mut includes, _py_ldflags) = pyc_e |
| 25 .and_then(|pyc| { |
25 .and_then(|pyc| { |
| 26 pyc.include_paths() |
26 pyc.include_paths() |
| 27 .and_then(|ip| pyc.ldflags().map(|ld| (pyc, ip, ld))) |
27 .and_then(|ip| pyc.ldflags().map(|ld| (pyc, ip, ld))) |
| 28 }) |
28 }) |
| 29 .map_err(|e| anyhow::Error::from(std::io::Error::from(e)))?; |
29 .map_err(|e| anyhow::Error::from(std::io::Error::from(e)))?; |
| 30 |
30 |
| 31 let nanobind_root = pyc |
31 let prefix = prefix_override.ok_or_else(|| pyc.prefix_path()).unwrap(); |
| 32 .prefix_path().ok() |
32 let version = pyc.semantic_version().unwrap(); |
| 33 .zip(pyc.semantic_version().ok()) |
33 |
| 34 .and_then(|(prefix, version)| { |
34 let nanobind_root = ({ |
| 35 info!("{}Python {} found at prefix {}", if py_conda { "Conda " } else { ""}, version, prefix.display()); |
35 info!("{}{}Python {} found at prefix {}", py_type.unwrap_or(""), if py_type.is_none() { "" } else { " "}, version, prefix.display()); |
| 36 let nanobind_root = prefix |
36 let nanobind_root = prefix |
| 37 .join("lib") |
37 .join("lib") |
| 38 .join(format!("python{}.{}", version.major, version.minor)) |
38 .join(format!("python{}.{}", version.major, version.minor)) |
| 39 .join("site-packages") |
39 .join("site-packages") |
| 40 .join("nanobind"); |
40 .join("nanobind"); |