| 34 } |
34 } |
| 35 |
35 |
| 36 /// Looks up conda Python |
36 /// Looks up conda Python |
| 37 pub fn python_conda() -> Option<OsString> { |
37 pub fn python_conda() -> Option<OsString> { |
| 38 option_env!("CONDA_PREFIX").and_then(|conda_prefix| { |
38 option_env!("CONDA_PREFIX").and_then(|conda_prefix| { |
| 39 /* This does not point to the right place. |
|
| 40 option_env!("CONDA_PYTHON_EXE") |
|
| 41 .map(OsString::from) |
|
| 42 .or_else(|| { */ |
|
| 43 let py = PathBuf::from(conda_prefix).join("bin/python"); |
39 let py = PathBuf::from(conda_prefix).join("bin/python"); |
| 44 if py.exists() { |
40 if py.exists() { |
| 45 Some(py.into()) |
41 Some(py.into()) |
| 46 } else { |
42 } else { |
| 47 None |
43 None |
| 48 } |
44 } |
| 49 /* })*/ |
|
| 50 }) |
45 }) |
| 51 } |
46 } |
| 52 |
47 |
| 53 /// Returns a the python configuration and indication whether it's from Conda |
48 /// Returns a the python configuration and indication whether it's from Conda |
| 54 pub fn python_config() -> (Result<PythonConfig, PyCError>, bool) { |
49 pub fn python_config() -> ( |
| 55 if let Some(py) = python_conda() { |
50 Result<PythonConfig, PyCError>, |
| 56 (PythonConfig::interpreter(py), true) |
51 Option<PathBuf>, |
| |
52 Option<&'static str>, |
| |
53 ) { |
| |
54 if let Some(py) = option_env!("VIRTUAL_ENV") { |
| |
55 let interp = PathBuf::from(py).join("bin/python"); |
| |
56 ( |
| |
57 PythonConfig::interpreter(interp), |
| |
58 Some(py.into()), |
| |
59 Some("venv"), |
| |
60 ) |
| |
61 } else if let Some(py) = python_conda() { |
| |
62 (PythonConfig::interpreter(py), None, Some("conda")) |
| 57 } else { |
63 } else { |
| 58 (Ok(PythonConfig::new()), false) |
64 (Ok(PythonConfig::new()), None, None) |
| 59 } |
65 } |
| 60 } |
66 } |
| 61 |
67 |
| 62 /* |
68 /* |
| 63 /// Looks up python includes given executable |
69 /// Looks up python includes given executable |