diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-16 23:20:27 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-19 06:53:57 +0100 |
commit | 1323cd8ac47060bb70e54103c0a4e18d3886e703 (patch) | |
tree | d5d70d3885ed80267b2f67e7442e2d8415d1babc /sources/shiboken2 | |
parent | 4d12849bc72cd54f4aec3118f9daf89af156e2c2 (diff) |
Replace imp by importlib
Getting rid of the DeprecationWarning
Change-Id: I86370c266d502fcd0fb61a9945770354b8f87142
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2')
-rw-r--r-- | sources/shiboken2/data/shiboken_helpers.cmake | 17 |
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) |