Skip to content

Commit dd8c99b

Browse files
committed
use PyQt4 where deprecated pyqtconfig is unavailable (fixes #10596 and fixes #11465)
1 parent f213254 commit dd8c99b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

cmake/FindPyQt.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,29 @@
3030
# Redistribution and use is allowed according to the terms of the BSD license.
3131
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
3232

33-
import PyQt4.pyqtconfig
33+
try:
34+
import PyQt4.pyqtconfig
35+
pyqtcfg = PyQt4.pyqtconfig.Configuration()
36+
except ImportError:
37+
import PyQt4.QtCore
38+
import sipconfig # won't work for SIP v5
39+
import os.path
40+
cfg = sipconfig.Configuration()
41+
sip_dir = cfg.default_sip_dir
42+
for p in (os.path.join(sip_dir, "PyQt4"), sip_dir):
43+
if os.path.exists(os.path.join(p, "QtCore", "QtCoremod.sip")):
44+
sip_dir = p
45+
break
46+
cfg = {
47+
'pyqt_version': PyQt4.QtCore.PYQT_VERSION,
48+
'pyqt_version_str': PyQt4.QtCore.PYQT_VERSION_STR,
49+
'pyqt_sip_flags': PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags'],
50+
'pyqt_mod_dir': cfg.default_mod_dir,
51+
'pyqt_sip_dir': sip_dir,
52+
'pyqt_bin_dir': cfg.default_bin_dir,
53+
}
54+
pyqtcfg = sipconfig.Configuration([cfg])
3455

35-
pyqtcfg = PyQt4.pyqtconfig.Configuration()
3656
print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
3757
print("pyqt_version_num:%d" % pyqtcfg.pyqt_version)
3858
print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)

0 commit comments

Comments
 (0)