aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-25 15:04:49 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-25 18:02:09 +0000
commit3b90ea342b3f91d82a16a1c64dc555f1f3117261 (patch)
treee8b21e63713eeb5281679d8d155ab9ab8c98e982 /examples
parent1f4056a1e6ad5f440c2ce890ee9b1f76d677d7d8 (diff)
utils/pyside2_config.py: Fix warning about module imp being deprecated as of Python 3.4
Enclose in a function returning the suffixes, fixing: pyside-setup/examples/scriptableapplication/../utils/pyside2_config.py:41: DeprecationWarning: the imp module is deprecated in favor of importlib; see the module's documentation for alternative uses import os, glob, re, sys, imp pyside/pyside-setup/examples/scriptableapplication/../utils/pyside2_config.py:41: DeprecationWarning: the imp module is deprecated in favor of importlib; see the module's documentation for alternative uses import os, glob, re, sys, imp pyside/pyside-setup/examples/scriptableapplication/../utils/pyside2_config.py:41: DeprecationWarning: the imp module is deprecated in favor of importlib; see the module's documentation for alternative uses import os, glob, re, sys, imp Change-Id: I2298303cb84f9037d5848aca722506adbf1151ba Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/utils/pyside2_config.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/examples/utils/pyside2_config.py b/examples/utils/pyside2_config.py
index 298d40d5b..21a1238b1 100644
--- a/examples/utils/pyside2_config.py
+++ b/examples/utils/pyside2_config.py
@@ -38,7 +38,7 @@
##
#############################################################################
-import os, glob, re, sys, imp
+import os, glob, re, sys
from distutils import sysconfig
usage = """
@@ -68,6 +68,21 @@ def sharedLibrarySuffix():
else:
return 'so.*'
+def importSuffixes():
+ if (sys.version_info >= (3, 4)):
+ import importlib
+ return importlib.machinery.EXTENSION_SUFFIXES
+ else:
+ import imp
+ result = []
+ for t in imp.get_suffixes():
+ result.append(t[0])
+ return result
+
+def isDebug():
+ debugSuffix = '_d.pyd' if sys.platform == 'win32' else '_d.so'
+ return any([s.endswith(debugSuffix) for s in importSuffixes()])
+
def sharedLibraryGlobPattern():
glob = '*.' + sharedLibrarySuffix()
return glob if sys.platform == 'win32' else 'lib' + glob
@@ -149,7 +164,7 @@ def pythonLinkData():
flags = {}
flags['libdir'] = libdir
if sys.platform == 'win32':
- suffix = '_d' if any([tup[0].endswith('_d.pyd') for tup in imp.get_suffixes()]) else ''
+ suffix = '_d' if isDebug() else ''
flags['lib'] = 'python{}{}'.format(version_no_dots, suffix)
elif sys.platform == 'darwin':
@@ -158,7 +173,7 @@ def pythonLinkData():
# Linux and anything else
else:
if sys.version_info[0] < 3:
- suffix = '_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else ''
+ suffix = '_d' if isDebug() else ''
flags['lib'] = 'python{}{}'.format(version, suffix)
else:
flags['lib'] = 'python{}{}'.format(version, sys.abiflags)