summarylogtreecommitdiffstats
path: root/pyqt411.patch
blob: 7d4fda1cef6d05500d7670ce1f09508f03bdcbe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
From 92f404ef8112448ac0a0ed04b031b348ff192b69 Mon Sep 17 00:00:00 2001
From: Dirk Thomas <dthomas@osrfoundation.org>
Date: Wed, 22 Apr 2015 18:10:02 -0700
Subject: [PATCH] support PyQt4.11 and higher when built with configure-ng.py

---
 cmake/sip_configure.py | 53 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 9 deletions(-)

diff --git a/cmake/sip_configure.py b/cmake/sip_configure.py
index dc2020d..df3778b 100644
--- a/cmake/sip_configure.py
+++ b/cmake/sip_configure.py
@@ -2,7 +2,35 @@
 import re
 import subprocess
 import sys
-from PyQt4 import pyqtconfig
+
+import sipconfig
+try:
+    from PyQt4.pyqtconfig import Configuration
+except ImportError:
+    # PyQt >= 4.11 has no pyqtconfig module if built with configure-ng.py
+    from PyQt4 import QtCore
+
+    class Configuration(sipconfig.Configuration):
+        def __init__(self):
+            qtconfig = subprocess.check_output(['qmake-qt4', '-query'], universal_newlines=True)
+            qtconfig = dict(line.split(':', 1) for line in qtconfig.splitlines())
+            pyqtconfig = {
+                'qt_archdata_dir': qtconfig['QT_INSTALL_DATA'],
+                'qt_data_dir': qtconfig['QT_INSTALL_DATA'],
+                'qt_dir': qtconfig['QT_INSTALL_PREFIX'],
+                'qt_inc_dir': qtconfig['QT_INSTALL_HEADERS'],
+                'qt_lib_dir': qtconfig['QT_INSTALL_LIBS'],
+                'qt_threaded': 1,
+                'qt_version': QtCore.QT_VERSION,
+                'qt_winconfig': 'shared',
+            }
+            sipconfig.Configuration.__init__(self, [pyqtconfig])
+
+            macros = sipconfig._default_macros.copy()
+            macros['INCDIR_QT'] = qtconfig['QT_INSTALL_HEADERS']
+            macros['LIBDIR_QT'] = qtconfig['QT_INSTALL_LIBS']
+            macros['MOC'] = 'moc-qt4'
+            self.set_build_macros(macros)
 
 if len(sys.argv) != 8:
     print('usage: %s build-dir sip-file output_dir include_dirs libs lib_dirs ldflags' % sys.argv[0])
@@ -15,12 +43,18 @@
 build_file = 'pyqtscripting.sbf'
 
 # Get the PyQt configuration information.
-config = pyqtconfig.Configuration()
+config = Configuration()
 
 # Get the extra SIP flags needed by the imported qt module.  Note that
 # this normally only includes those flags (-x and -t) that relate to SIP's
 # versioning system.
-qt_sip_flags = config.pyqt_sip_flags
+try:
+    sip_dir = config.pyqt_sip_dir
+    sip_flags = config.pyqt_sip_flags
+except AttributeError:
+    # sipconfig.Configuration does not have a pyqt_sip_dir or pyqt_sip_flags attribute
+    sip_dir = sipconfig._pkg_config['default_sip_dir'] + '/PyQt4'
+    sip_flags = QtCore.PYQT_CONFIGURATION['sip_flags']
 
 try:
     os.makedirs(build_dir)
@@ -33,31 +67,32 @@
     config.sip_bin,
     '-c', build_dir,
     '-b', os.path.join(build_dir, build_file),
-    '-I', config.pyqt_sip_dir,
+    '-I', sip_dir,
     '-w'
 ]
-cmd += qt_sip_flags.split(' ')
+cmd += sip_flags.split(' ')
 cmd.append(sip_file)
 subprocess.check_call(cmd)
 
 # Create the Makefile.  The QtModuleMakefile class provided by the
 # pyqtconfig module takes care of all the extra preprocessor, compiler and
 # linker flags needed by the Qt library.
-makefile = pyqtconfig.QtGuiModuleMakefile(
+makefile = sipconfig.SIPModuleMakefile(
     dir=build_dir,
     configuration=config,
-    build_file=build_file
+    build_file=build_file,
+    qt=['QtCore', 'QtGui']
 )
 
 # hack to override makefile behavior which always prepend -l to libraries which is wrong for absolute paths
-default_platform_lib_function = pyqtconfig.QtGuiModuleMakefile.platform_lib
+default_platform_lib_function = sipconfig.SIPModuleMakefile.platform_lib
 
 
 def custom_platform_lib_function(self, clib, framework=0):
     if os.path.isabs(clib):
         return clib
     return default_platform_lib_function(self, clib, framework)
-pyqtconfig.QtGuiModuleMakefile.platform_lib = custom_platform_lib_function
+sipconfig.SIPModuleMakefile.platform_lib = custom_platform_lib_function
 
 
 # split paths on whitespace