aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/data/shiboken_helpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/data/shiboken_helpers.cmake')
-rw-r--r--sources/shiboken2/data/shiboken_helpers.cmake17
1 files changed, 11 insertions, 6 deletions
diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake
index 8111fa61f..5d7ff56bb 100644
--- a/sources/shiboken2/data/shiboken_helpers.cmake
+++ b/sources/shiboken2/data/shiboken_helpers.cmake
@@ -221,15 +221,20 @@ macro(set_quiet_build)
endmacro()
macro(get_python_extension_suffix)
- # Result of imp.get_suffixes() depends on the platform, but generally looks something like:
- # [('.cpython-34m-x86_64-linux-gnu.so', 'rb', 3), ('.cpython-34m.so', 'rb', 3),
- # ('.abi3.so', 'rb', 3), ('.so', 'rb', 3), ('.py', 'r', 1), ('.pyc', 'rb', 2)]
- # We pick the first most detailed one, strip of the file extension part.
+ # Result of importlib.machinery.EXTENSION_SUFFIXES depends on the platform,
+ # but generally looks something like:
+ # ['.cpython-38-x86_64-linux-gnu.so', '.abi3.so', '.so']
+ # We pick the first most detailed one.
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "if True:
- import imp, re
- first_suffix = imp.get_suffixes()[0][0]
+ import re
+ try:
+ from importlib import machinery
+ first_suffix = machinery.EXTENSION_SUFFIXES[0]
+ except AttributeError:
+ import imp
+ first_suffix = imp.get_suffixes()[0][0]
res = re.search(r'^(.+)\\.', first_suffix)
if res:
first_suffix = res.group(1)