From cb587a338d184ba3097ff5fc4eb5b6af4ccb1643 Mon Sep 17 00:00:00 2001 From: Sergey Kvachonok Date: Sat, 9 Apr 2022 12:01:07 +0300 Subject: [PATCH] pyo3-build-config: Use "m" ABI tag for libpython 3.7 by default According to https://bugs.python.org/issue36707, this tag is useless since version 3.4, but also the default until version 3.8. For example, Debian 10 ships `libpython3.7m.so`. --- pyo3-build-config/src/impl_.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index afcb6494c13..581004c4a90 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -1505,7 +1505,15 @@ fn default_lib_name_unix( match implementation { PythonImplementation::CPython => match ld_version { Some(ld_version) => format!("python{}", ld_version), - None => format!("python{}.{}", version.major, version.minor), + None => { + if version > PythonVersion::PY37 { + // PEP 3149 ABI version tags are finally gone + format!("python{}.{}", version.major, version.minor) + } else { + // Work around https://bugs.python.org/issue36707 + format!("python{}.{}m", version.major, version.minor) + } + } }, PythonImplementation::PyPy => { if version >= (PythonVersion { major: 3, minor: 9 }) { @@ -2142,10 +2150,15 @@ mod tests { #[test] fn default_lib_name_unix() { use PythonImplementation::*; - // Defaults to pythonX.Y for CPython + // Defaults to python3.7m for CPython 3.7 assert_eq!( super::default_lib_name_unix(PythonVersion { major: 3, minor: 7 }, CPython, None), - "python3.7", + "python3.7m", + ); + // Defaults to pythonX.Y for CPython 3.8+ + assert_eq!( + super::default_lib_name_unix(PythonVersion { major: 3, minor: 8 }, CPython, None), + "python3.8", ); assert_eq!( super::default_lib_name_unix(PythonVersion { major: 3, minor: 9 }, CPython, None),