From ceb6dbf76688d1d25e65f1d03d1c5589a5665228 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 9 Jun 2021 08:58:18 +0800 Subject: [PATCH] Detect Python implementation from `SOABI` on Unix --- pyo3-build-config/src/impl_.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 9146a55f..c94aa466 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -358,6 +358,7 @@ fn parse_sysconfigdata(config_path: impl AsRef) -> Result format!("{}.{}", major, minor), }; let calcsize_pointer = sysconfig_data.get_numeric("SIZEOF_VOID_P").ok(); + let soabi = match sysconfig_data.get("SOABI") { + Some(s) => s, + None => bail!("sysconfigdata did not define SOABI"), + }; let version = PythonVersion { major, minor }; - let implementation = PythonImplementation::CPython; + let implementation = if soabi.starts_with("pypy") { + PythonImplementation::PyPy + } else if soabi.starts_with("cpython") { + PythonImplementation::CPython + } else { + bail!("unsupported Python interpreter"); + }; Ok(InterpreterConfig { version,