summaryrefslogtreecommitdiff
path: root/libre/kdelibs-libre/pyqt.patch
blob: eadd2f2ac1b30e893c90277fd801be2e2fede147 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
Make FindPyKDE4 work with PyQt's new build system.
Make FindPyQt4 work with PyQt's new build system.

Since PyQt 4.10, PyQt.pyqtconfig is deprecated and not available unless
PyQt is built using the old configure script.

PyKDE4 itself has recently been adjusted to mimic PyQt itself and only
install its pykdeconfig module if pyqtconfig is present. Additionally,
information such as SIP flags and the directory where PyKDE's SIP files
are installed are now also provided in the
PyKDE4.kdecore.PYKDE_CONFIGURATION dict.

This commit completely rewrites FindPyKDE4.py to make it look like
FindPyQt.cmake after commit a7e4743: most of the information used by
FindPyKDE4.cmake is fetched from PyKDE4.kdecore, and we first try to
obtain the SIP flags and directory from pykdeconfig and, if it fails, we
use PYKDE_CONFIGURATION.

Furthermore, FindPyKDE4.py now only prints the variables that are
actually consumed by FindPyKDE4.cmake -- it is not possible to obtain
all the data provided by pykdeconfig in PYKDE_CONFIGURATION. We've also
stopped reading and setting PYKDE4_VERSION_TAG, since PyKDE4 stopped
setting a KDE tag in 2008 (and its value was 3_92_0 at the time).

CCBUG: 327633
REVIEW: 119454

BUG: 337462
FIXED-IN: 4.14.0
REVIEW: 119302
--- kdelibs-4.13.3/cmake/modules/FindPyKDE4.cmake~	2014-08-06 21:54:27.564432282 +0000
+++ kdelibs-4.13.3/cmake/modules/FindPyKDE4.cmake	2014-08-06 21:54:43.417702615 +0000
@@ -25,7 +25,6 @@
     STRING(REGEX REPLACE ".*\npykde_version_str:([^\n]+).*$" "\\1" PYKDE4_VERSION_STR ${pykde_config})
     STRING(REGEX REPLACE ".*\npykde_kde_sip_flags:([^\n]+).*$" "\\1" PYKDE4_SIP_FLAGS ${pykde_config})
     STRING(REGEX REPLACE ".*\npykde_sip_dir:([^\n]+).*$" "\\1" PYKDE4_SIP_DIR ${pykde_config})
-    STRING(REGEX REPLACE ".*\npykde_version_tag:([^\n]+).*$" "\\1" PYKDE4_VERSION_TAG ${pykde_config})
     MESSAGE(STATUS "Found PyKDE4 version ${PYKDE4_VERSION_STR} ${PYKDE4_SIP_DIR}")
 
     SET(PYKDE4_FOUND TRUE)
@@ -183,3 +182,4 @@
     endif(WIN32)
 ENDMACRO(PYKDE4_ADD_EXECUTABLE)
 
+
--- kdelibs-4.13.3/cmake/modules/FindPyKDE4.py~	2014-08-06 21:54:56.427650960 +0000
+++ kdelibs-4.13.3/cmake/modules/FindPyKDE4.py	2014-08-06 21:55:04.400952596 +0000
@@ -1,46 +1,23 @@
-# By Simon Edwards <simon@simonzone.com>
-# modified by Paul Giannaros <paul@giannaros.org> to add better PyKDE4
-# sip directory finding
-# This file is in the public domain.
+# Copyright (c) 2014, Raphael Kubo da Costa <rakuco@FreeBSD.org>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-import sys
-import os
-import PyKDE4.pykdeconfig
-import PyQt4.pyqtconfig
+import PyKDE4.kdecore
 
-if "_pkg_config" in dir(PyKDE4.pykdeconfig):
-    _pkg_config = PyKDE4.pykdeconfig._pkg_config
+if __name__ == '__main__':
+    try:
+        import PyKDE4.pykdeconfig
+        pykdecfg = PyKDE4.pykdeconfig.Configuration()
+        sip_dir = pykdecfg.pykde_sip_dir
+        sip_flags = pykdecfg.pykde_kde_sip_flags
+    except ImportError:
+        # PyQt4 >= 4.10.0 was built with configure-ng.py instead of
+        # configure.py, so pyqtconfig.py and pykdeconfig.py are not installed.
+        sip_dir = PyKDE4.kdecore.PYKDE_CONFIGURATION['sip_dir']
+        sip_flags = PyKDE4.kdecore.PYKDE_CONFIGURATION['sip_flags']
 
-    for varname in [
-            'kde_version',
-            'kde_version_extra',
-            'kdebasedir',
-            'kdeincdir',
-            'kdelibdir',
-            'libdir',
-            'pykde_kde_sip_flags', 
-            'pykde_mod_dir',
-            'pykde_modules', 
-            'pykde_sip_dir',
-            'pykde_version',
-            'pykde_version_str']:
-        varvalue = _pkg_config[varname]
-        if varname == 'pykde_sip_dir':
-            d = os.path.join(_pkg_config[varname], 'PyKDE4')
-            if os.path.exists(d):
-                varvalue = d
-        print("%s:%s\n" % (varname, varvalue))
-    pykde_version_tag = ''
-    in_t = False
-    for item in _pkg_config['pykde_kde_sip_flags'].split():
-        if item == "-t":
-            in_t = True
-        elif in_t:
-            if item.startswith("KDE_"):
-                pykde_version_tag = item
-        else:
-            in_t = False
-    print("pykde_version_tag:%s" % pykde_version_tag)
+    print('pykde_version:%06.x' % PyKDE4.kdecore.version())
+    print('pykde_version_str:%s' % PyKDE4.kdecore.versionString())
+    print('pykde_sip_dir:%s' % sip_dir)
+    print('pykde_sip_flags:%s' % sip_flags)
 
-else:
-    sys.exit(1)
--- kdelibs-4.13.3/cmake/modules/FindPyQt.py~	2014-08-06 21:55:55.874081319 +0000
+++ kdelibs-4.13.3/cmake/modules/FindPyQt.py	2014-08-06 21:56:06.250706848 +0000
@@ -1,24 +1,49 @@
 # Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
+# Copyright (c) 2014, Raphael Kubo da Costa <rakuco@FreeBSD.org>
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-import PyQt4.pyqtconfig
+import PyQt4.QtCore
+import os
+import sys
 
-pyqtcfg = PyQt4.pyqtconfig.Configuration()
-print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
-print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)
-
-pyqt_version_tag = ""
-in_t = False
-for item in pyqtcfg.pyqt_sip_flags.split(' '):
-    if item=="-t":
-        in_t = True
-    elif in_t:
-        if item.startswith("Qt_4"):
-            pyqt_version_tag = item
+def get_default_sip_dir():
+    # This is based on QScintilla's configure.py, and only works for the
+    # default case where installation paths have not been changed in PyQt's
+    # configuration process.
+    if sys.platform == 'win32':
+        pyqt_sip_dir = os.path.join(sys.prefix, 'sip', 'PyQt4')
     else:
-        in_t = False
-print("pyqt_version_tag:%s" % pyqt_version_tag)
+        pyqt_sip_dir = os.path.join(sys.prefix, 'share', 'sip', 'PyQt4')
+    return pyqt_sip_dir
+
+def get_qt4_tag(sip_flags):
+    in_t = False
+    for item in sip_flags.split(' '):
+        if item == '-t':
+            in_t = True
+        elif in_t:
+            if item.startswith('Qt_4'):
+                return item
+        else:
+            in_t = False
+    raise ValueError('Cannot find Qt\'s tag in PyQt4\'s SIP flags.')
+
+if __name__ == '__main__':
+    try:
+        import PyQt4.pyqtconfig
+        pyqtcfg = PyQt4.pyqtconfig.Configuration()
+        sip_dir = pyqtcfg.pyqt_sip_dir
+        sip_flags = pyqtcfg.pyqt_sip_flags
+    except ImportError:
+        # PyQt4 >= 4.10.0 was built with configure-ng.py instead of
+        # configure.py, so pyqtconfig.py is not installed.
+        sip_dir = get_default_sip_dir()
+        sip_flags = PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags']
+
+    print('pyqt_version:%06.x' % PyQt4.QtCore.PYQT_VERSION)
+    print('pyqt_version_str:%s' % PyQt4.QtCore.PYQT_VERSION_STR)
+    print('pyqt_version_tag:%s' % get_qt4_tag(sip_flags))
+    print('pyqt_sip_dir:%s' % sip_dir)
+    print('pyqt_sip_flags:%s' % sip_flags)
 
-print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
-print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
--- kdelibs-4.13.3/cmake/modules/FindPyQt4.cmake~	2014-08-06 21:55:16.697570407 +0000
+++ kdelibs-4.13.3/cmake/modules/FindPyQt4.cmake	2014-08-06 21:55:38.597483393 +0000
@@ -9,16 +9,20 @@
 # Find the installed version of PyQt4. FindPyQt4 should only be called after
 # Python has been found.
 #
-# This file defines the following variables:
+# This file defines the following variables, which can also be overriden by
+# users:
 #
 # PYQT4_VERSION - The version of PyQt4 found expressed as a 6 digit hex number
 #     suitable for comparison as a string
 #
 # PYQT4_VERSION_STR - The version of PyQt4 as a human readable string.
 #
-# PYQT4_VERSION_TAG - The PyQt version tag using by PyQt's sip files.
+# PYQT4_VERSION_TAG - The Qt4 version tag used by PyQt's sip files.
 #
-# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files.
+# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files. This can be unset
+# if PyQt4 was built using its new build system and pyqtconfig.py is not
+# present on the system, as in this case its value cannot be determined
+# automatically.
 #
 # PYQT4_SIP_FLAGS - The SIP flags used to build PyQt.
 
@@ -31,13 +35,27 @@
 
   EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt_py} OUTPUT_VARIABLE pyqt_config)
   IF(pyqt_config)
-    STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
-    STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
-    STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
-    STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
-    STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})
+    STRING(REGEX MATCH "^pyqt_version:([^\n]+).*$" _dummy ${pyqt_config})
+    SET(PYQT4_VERSION "${CMAKE_MATCH_1}" CACHE STRING "PyQt4's version as a 6-digit hexadecimal number")
 
-    SET(PYQT4_FOUND TRUE)
+    STRING(REGEX MATCH ".*\npyqt_version_str:([^\n]+).*$" _dummy ${pyqt_config})
+    SET(PYQT4_VERSION_STR "${CMAKE_MATCH_1}" CACHE STRING "PyQt4's version as a human-readable string")
+
+    STRING(REGEX MATCH ".*\npyqt_version_tag:([^\n]+).*$" _dummy ${pyqt_config})
+    SET(PYQT4_VERSION_TAG "${CMAKE_MATCH_1}" CACHE STRING "The Qt4 version tag used by PyQt4's .sip files")
+
+    STRING(REGEX MATCH ".*\npyqt_sip_dir:([^\n]+).*$" _dummy ${pyqt_config})
+    SET(PYQT4_SIP_DIR "${CMAKE_MATCH_1}" CACHE PATH "The base directory where PyQt4's .sip files are installed")
+
+    STRING(REGEX MATCH ".*\npyqt_sip_flags:([^\n]+).*$" _dummy ${pyqt_config})
+    SET(PYQT4_SIP_FLAGS "${CMAKE_MATCH_1}" CACHE STRING "The SIP flags used to build PyQt4")
+
+    IF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
+      MESSAGE(WARNING "The base directory where PyQt4's SIP files are installed could not be determined. This usually means PyQt4 was built with its new build system and pyqtconfig.py is not present.\n"
+                      "Please set the PYQT4_SIP_DIR variable manually.")
+    ELSE(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
+      SET(PYQT4_FOUND TRUE)
+    ENDIF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
   ENDIF(pyqt_config)
 
   IF(PYQT4_FOUND)
@@ -51,3 +69,4 @@
   ENDIF(PYQT4_FOUND)
 
 ENDIF(EXISTS PYQT4_VERSION)
+