Extract compilation vars from the specified interpreter.
(
interpreter: &str,
)
| 313 | |
| 314 | /// Extract compilation vars from the specified interpreter. |
| 315 | fn get_config_from_interpreter( |
| 316 | interpreter: &str, |
| 317 | ) -> Result<(String, PythonVersion, Vec<String>), String> { |
| 318 | let script = "import sys; import sysconfig; print(sys.executable); \ |
| 319 | print(sys.version_info[0:2]); \ |
| 320 | print(sysconfig.get_config_var('LIBDIR')); \ |
| 321 | print(sysconfig.get_config_var('Py_ENABLE_SHARED')); \ |
| 322 | print(sysconfig.get_config_var('LDVERSION') or '%s%s' % (sysconfig.get_config_var('py_version_short'), sysconfig.get_config_var('DEBUG_EXT') or '')); \ |
| 323 | print(sys.exec_prefix);"; |
| 324 | let out = run_python_script(interpreter, script)?; |
| 325 | let mut lines: Vec<String> = out |
| 326 | .split(NEWLINE_SEQUENCE) |
| 327 | .map(|line| line.to_owned()) |
| 328 | .collect(); |
| 329 | let executable = lines.remove(0); |
| 330 | let interpreter_version = lines.remove(0); |
| 331 | let interpreter_version = get_interpreter_version(&interpreter_version)?; |
| 332 | Ok((executable, interpreter_version, lines)) |
| 333 | } |
| 334 | |
| 335 | /// Deduce configuration from the 'python' in the current PATH and print |
| 336 | /// cargo vars to stdout. |
no test coverage detected