]>
Commit | Line | Data |
---|---|---|
1128a89b RD |
1 | #---------------------------------------------------------------------- |
2 | # Name: wx.build.config | |
3 | # Purpose: Most of the contents of this module used to be located | |
4 | # in wxPython's setup.py script. It was moved here so | |
5 | # it would be installed with the rest of wxPython and | |
6 | # could therefore be used by the setup.py for other | |
7 | # projects that needed this same info and functionality | |
8 | # (most likely in order to be compatible with wxPython.) | |
9 | # | |
10 | # This split from setup.py is still fairly rough, and | |
11 | # some things may still get shuffled back and forth, | |
12 | # refactored, etc. Please send me any comments and | |
13 | # suggestions about this. | |
14 | # | |
15 | # Author: Robin Dunn | |
16 | # | |
17 | # Created: 23-March-2004 | |
18 | # RCS-ID: $Id$ | |
19 | # Copyright: (c) 2004 by Total Control Software | |
20 | # Licence: wxWindows license | |
21 | #---------------------------------------------------------------------- | |
22 | ||
23 | import sys, os, glob, fnmatch, tempfile | |
24 | from distutils.core import setup, Extension | |
25 | from distutils.file_util import copy_file | |
26 | from distutils.dir_util import mkpath | |
27 | from distutils.dep_util import newer | |
28 | from distutils.spawn import spawn | |
29 | ||
30 | import distutils.command.install_data | |
31 | import distutils.command.install_headers | |
32 | import distutils.command.clean | |
33 | ||
73a22369 RD |
34 | #################################### |
35 | # BuildRenamers | |
36 | #################################### | |
37 | ||
38 | import pprint | |
39 | import xml.sax | |
40 | from distutils.spawn import spawn | |
41 | ||
42 | try: | |
43 | import libxml2 | |
44 | FOUND_LIBXML2 = True | |
45 | except ImportError: | |
46 | FOUND_LIBXML2 = False | |
47 | ||
48 | #--------------------------------------------------------------------------- | |
49 | ||
50 | ||
51 | renamerTemplateStart = """\ | |
52 | // A bunch of %rename directives generated by BuildRenamers in config.py | |
53 | // in order to remove the wx prefix from all global scope names. | |
54 | ||
55 | #ifndef BUILDING_RENAMERS | |
56 | ||
57 | """ | |
58 | ||
59 | renamerTemplateEnd = """ | |
60 | #endif | |
61 | """ | |
62 | ||
63 | wxPythonTemplateStart = """\ | |
64 | ## This file reverse renames symbols in the wx package to give | |
65 | ## them their wx prefix again, for backwards compatibility. | |
66 | ## | |
67 | ## Generated by BuildRenamers in config.py | |
68 | ||
69 | # This silly stuff here is so the wxPython.wx module doesn't conflict | |
70 | # with the wx package. We need to import modules from the wx package | |
71 | # here, then we'll put the wxPython.wx entry back in sys.modules. | |
72 | import sys | |
73 | _wx = None | |
74 | if sys.modules.has_key('wxPython.wx'): | |
75 | _wx = sys.modules['wxPython.wx'] | |
76 | del sys.modules['wxPython.wx'] | |
77 | ||
78 | import wx.%s | |
79 | ||
80 | sys.modules['wxPython.wx'] = _wx | |
81 | del sys, _wx | |
82 | ||
83 | ||
84 | # Now assign all the reverse-renamed names: | |
85 | """ | |
86 | ||
87 | wxPythonTemplateEnd = """ | |
88 | ||
89 | """ | |
90 | ||
91 | ||
92 | ||
93 | #--------------------------------------------------------------------------- | |
94 | class BuildRenamers: | |
95 | def run(self, destdir, modname, xmlfile, wxPythonDir="wxPython"): | |
96 | ||
97 | assert FOUND_LIBXML2, "The libxml2 module is required to use the BuildRenamers functionality." | |
98 | ||
99 | swigDest = os.path.join(destdir, "_"+modname+"_rename.i") | |
100 | pyDest = os.path.join(wxPythonDir, modname + '.py') | |
101 | ||
102 | swigDestTemp = tempfile.mktemp('.tmp') | |
103 | swigFile = open(swigDestTemp, "w") | |
104 | swigFile.write(renamerTemplateStart) | |
105 | ||
106 | pyDestTemp = tempfile.mktemp('.tmp') | |
107 | pyFile = open(pyDestTemp, "w") | |
108 | pyFile.write(wxPythonTemplateStart % modname) | |
109 | ||
110 | print "Parsing XML and building renamers..." | |
111 | self.processXML(xmlfile, modname, swigFile, pyFile) | |
112 | ||
113 | self.checkOtherNames(pyFile, modname, | |
114 | os.path.join(destdir, '_'+modname+'_reverse.txt')) | |
115 | pyFile.write(wxPythonTemplateEnd) | |
116 | pyFile.close() | |
117 | ||
118 | swigFile.write(renamerTemplateEnd) | |
119 | swigFile.close() | |
120 | ||
121 | # Compare the files just created with the existing one and | |
122 | # blow away the old one if they are different. | |
123 | for dest, temp in [(swigDest, swigDestTemp), | |
124 | (pyDest, pyDestTemp)]: | |
125 | if not os.path.exists(dest): | |
126 | os.rename(temp, dest) | |
127 | elif open(dest).read() != open(temp).read(): | |
128 | os.unlink(dest) | |
129 | os.rename(temp, dest) | |
130 | else: | |
131 | print dest + " not changed." | |
132 | os.unlink(temp) | |
133 | ||
134 | #--------------------------------------------------------------------------- | |
135 | ||
136 | ||
137 | def GetAttr(self, node, name): | |
138 | path = "./attributelist/attribute[@name='%s']/@value" % name | |
139 | n = node.xpathEval2(path) | |
140 | if len(n): | |
141 | return n[0].content | |
142 | else: | |
143 | return None | |
144 | ||
145 | ||
146 | def processXML(self, xmlfile, modname, swigFile, pyFile): | |
147 | ||
148 | topnode = libxml2.parseFile(xmlfile).children | |
149 | ||
150 | # remove any import nodes as we don't need to do renamers for symbols found therein | |
151 | imports = topnode.xpathEval2("*/import") | |
152 | for n in imports: | |
153 | n.unlinkNode() | |
154 | n.freeNode() | |
155 | ||
156 | # do a depth first iteration over what's left | |
157 | for node in topnode: | |
158 | doRename = False | |
159 | doPtr = False | |
160 | addWX = False | |
161 | revOnly = False | |
162 | ||
163 | ||
164 | if node.name == "class": | |
165 | lastClassName = name = self.GetAttr(node, "name") | |
166 | lastClassSymName = sym_name = self.GetAttr(node, "sym_name") | |
167 | doRename = True | |
168 | doPtr = True | |
169 | if sym_name != name: | |
170 | name = sym_name | |
171 | addWX = True | |
172 | ||
173 | # renamed constructors | |
174 | elif node.name == "constructor": | |
175 | name = self.GetAttr(node, "name") | |
176 | sym_name = self.GetAttr(node, "sym_name") | |
177 | if sym_name != name: | |
178 | name = sym_name | |
179 | addWX = True | |
180 | doRename = True | |
181 | ||
182 | # only enumitems at the top level | |
183 | elif node.name == "enumitem" and node.parent.parent.name == "include": | |
184 | name = self.GetAttr(node, "name") | |
185 | sym_name = self.GetAttr(node, "sym_name") | |
186 | doRename = True | |
187 | ||
188 | ||
189 | elif node.name in ["cdecl", "constant"]: | |
190 | name = self.GetAttr(node, "name") | |
191 | sym_name = self.GetAttr(node, "sym_name") | |
192 | toplevel = node.parent.name == "include" | |
193 | ||
194 | # top-level functions | |
195 | if toplevel and self.GetAttr(node, "view") == "globalfunctionHandler": | |
196 | doRename = True | |
197 | ||
198 | # top-level global vars | |
199 | elif toplevel and self.GetAttr(node, "feature_immutable") == "1": | |
200 | doRename = True | |
201 | ||
202 | # static methods | |
203 | elif self.GetAttr(node, "view") == "staticmemberfunctionHandler": | |
204 | name = lastClassName + '_' + name | |
205 | sym_name = lastClassSymName + '_' + sym_name | |
206 | # only output the reverse renamer in this case | |
207 | doRename = revOnly = True | |
208 | ||
209 | if doRename and name != sym_name: | |
210 | name = sym_name | |
211 | addWX = True | |
212 | ||
213 | ||
214 | if doRename and name: | |
215 | old = new = name | |
216 | if old.startswith('wx') and not old.startswith('wxEVT_'): | |
217 | # remove all wx prefixes except wxEVT_ and write a %rename directive for it | |
218 | new = old[2:] | |
219 | if not revOnly: | |
220 | swigFile.write("%%rename(%s) %35s;\n" % (new, old)) | |
221 | ||
222 | # Write assignments to import into the old wxPython namespace | |
223 | if addWX and not old.startswith('wx'): | |
224 | old = 'wx'+old | |
225 | pyFile.write("%s = wx.%s.%s\n" % (old, modname, new)) | |
226 | if doPtr: | |
227 | pyFile.write("%sPtr = wx.%s.%sPtr\n" % (old, modname, new)) | |
228 | ||
229 | ||
230 | #--------------------------------------------------------------------------- | |
231 | ||
232 | def checkOtherNames(self, pyFile, moduleName, filename): | |
233 | if os.path.exists(filename): | |
234 | prefixes = [] | |
235 | for line in file(filename): | |
236 | if line.endswith('\n'): | |
237 | line = line[:-1] | |
238 | if line and not line.startswith('#'): | |
239 | if line.endswith('*'): | |
240 | prefixes.append(line[:-1]) | |
241 | elif line.find('=') != -1: | |
242 | pyFile.write("%s\n" % line) | |
243 | else: | |
244 | wxname = 'wx' + line | |
245 | if line.startswith('wx') or line.startswith('WX') or line.startswith('EVT'): | |
246 | wxname = line | |
247 | pyFile.write("%s = wx.%s.%s\n" % (wxname, moduleName, line)) | |
248 | ||
249 | if prefixes: | |
250 | pyFile.write( | |
251 | "\n\nd = globals()\nfor k, v in wx.%s.__dict__.iteritems():" | |
252 | % moduleName) | |
253 | first = True | |
254 | for p in prefixes: | |
255 | if first: | |
256 | pyFile.write("\n if ") | |
257 | first = False | |
258 | else: | |
259 | pyFile.write("\n elif ") | |
260 | pyFile.write("k.startswith('%s'):\n d[k] = v" % p) | |
261 | pyFile.write("\ndel d, k, v\n\n") | |
262 | ||
263 | ||
264 | #--------------------------------------------------------------------------- | |
265 | ||
266 | ## interestingTypes = [ 'class', 'cdecl', 'enumitem', 'constructor', 'constant' ] | |
267 | ## interestingAttrs = [ 'name', 'sym_name', 'decl', 'feature_immutable', 'module', | |
268 | ## 'storage', 'type' ] | |
269 | ||
270 | ||
271 | ## class Element: | |
272 | ## def __init__(self, tagtype): | |
273 | ## self.tagtype = tagtype | |
274 | ## self.level = -1 | |
275 | ## self.name = None | |
276 | ## self.sym_name = None | |
277 | ## self.decl = None | |
278 | ## self.immutable = None | |
279 | ## self.klass = None | |
280 | ## self.module = None | |
281 | ## self.storage = None | |
282 | ## self.type = None | |
283 | ## self.startLine = -1 | |
284 | ||
285 | ||
286 | ## def write(self, moduleName, swigFile, pyFile): | |
287 | ## doRename = False | |
288 | ## doPtr = False | |
289 | ## addWX = False | |
290 | ## revOnly = False | |
291 | ||
292 | ## #if self.name.find('DefaultPosition') != -1: | |
293 | ## # pprint.pprint(self.__dict__) | |
294 | ||
295 | ## if self.tagtype in ['cdecl', 'constant']: | |
296 | ## if self.storage == 'typedef': | |
297 | ## pass | |
298 | ||
299 | ## # top level functions | |
300 | ## elif self.level == 0 and self.decl != "": | |
301 | ## doRename = True | |
302 | ||
303 | ## # top level global vars | |
304 | ## elif self.level == 0 and self.immutable == '1': | |
305 | ## doRename = True | |
306 | ||
307 | ## # static methods | |
308 | ## elif self.storage == 'static': | |
309 | ## if not self.klass: | |
310 | ## pprint.pprint(self.__dict__) | |
311 | ## else: | |
312 | ## self.name = self.klass + '_' + self.name | |
313 | ## self.sym_name = self.sym_klass + '_' + self.sym_name | |
314 | ## # only output the reverse renamer in this case | |
315 | ## doRename = revOnly = True | |
316 | ||
317 | ||
318 | ||
319 | ## if doRename and self.name != self.sym_name: | |
320 | ## #print "%-25s %-25s" % (self.name, self.sym_name) | |
321 | ## self.name = self.sym_name | |
322 | ## addWX = True | |
323 | ||
324 | ||
325 | ## elif self.tagtype == 'class' and self.module == moduleName: | |
326 | ## doRename = True | |
327 | ## doPtr = True | |
328 | ## if self.sym_name != self.klass: | |
329 | ## #print self.sym_name | |
330 | ## self.name = self.sym_name | |
331 | ## addWX = True | |
332 | ||
333 | ## elif self.tagtype == 'constructor': | |
334 | ## #print "%-25s %-25s" % (self.name, self.sym_name) | |
335 | ## if self.sym_name != self.klass: | |
336 | ## #print self.sym_name | |
337 | ## self.name = self.sym_name | |
338 | ## addWX = True | |
339 | ## doRename = True | |
340 | ||
341 | ## elif self.tagtype == 'enumitem' and self.level == 0: | |
342 | ## doRename = True | |
343 | ||
344 | ||
345 | ## if doRename: | |
346 | ## #print "%-25s %-25s" % (self.name, self.sym_name) | |
347 | ## old = new = self.name | |
348 | ## if old.startswith('wx') and not old.startswith('wxEVT_'): | |
349 | ## # remove all wx prefixes except wxEVT_ and write a %rename directive for it | |
350 | ## new = old[2:] | |
351 | ## if not revOnly: | |
352 | ## swigFile.write("%%rename(%s) %35s;\n" % (new, old)) | |
353 | ||
354 | ## # Write assignments to import into the old wxPython namespace | |
355 | ## if addWX and not old.startswith('wx'): | |
356 | ## old = 'wx'+old | |
357 | ## pyFile.write("%s = wx.%s.%s\n" % (old, moduleName, new)) | |
358 | ## if doPtr: | |
359 | ## pyFile.write("%sPtr = wx.%s.%sPtr\n" % (old, moduleName, new)) | |
360 | ||
361 | ||
362 | ||
363 | ## #else: | |
364 | ## # text = "%07d %d %10s %-35s %s\n" % ( | |
365 | ## # self.startLine, self.level, self.tagtype, self.name, self.decl) | |
366 | ## # #rejects.write(text) | |
367 | ## # print text, | |
368 | ||
369 | ||
370 | ## #--------------------------------------------------------------------------- | |
371 | ||
372 | ## class ContentHandler(xml.sax.ContentHandler): | |
373 | ## def __init__(self, modname, swigFile, pyFile): | |
374 | ## xml.sax.ContentHandler.__init__(self) | |
375 | ## self.modname = modname | |
376 | ## self.swigFile = swigFile | |
377 | ## self.pyFile = pyFile | |
378 | ## self.elements = [] | |
379 | ## self.imports = 0 | |
380 | ## self.klass = None | |
381 | ## self.sym_klass = None | |
382 | ||
383 | ||
384 | ## def setDocumentLocator(self, locator): | |
385 | ## self.locator = locator | |
386 | ||
387 | ||
388 | ||
389 | ## def startElement(self, name, attrs): | |
390 | ## if name in interestingTypes: | |
391 | ## # start of a new element that we are interested in | |
392 | ## ce = Element(name) | |
393 | ## ce.startLine = self.locator.getLineNumber() | |
394 | ## ce.level = len(self.elements) | |
395 | ## if name == 'constructor': | |
396 | ## ce.klass = self.elements[0].name | |
397 | ## else: | |
398 | ## ce.klass = self.klass | |
399 | ## ce.sym_klass = self.sym_klass | |
400 | ## self.elements.insert(0, ce) | |
401 | ||
402 | ||
403 | ## elif len(self.elements) and name == 'attribute' and attrs['name'] in interestingAttrs: | |
404 | ## attrName = attrs['name'] | |
405 | ## attrVal = attrs['value'] | |
406 | ## if attrName.startswith('feature_'): | |
407 | ## attrName = attrName.replace('feature_', '') | |
408 | ## ce = self.elements[0] | |
409 | ## if getattr(ce, attrName) is None: | |
410 | ## setattr(ce, attrName, attrVal) | |
411 | ## if ce.tagtype == 'class' and attrName == 'name' and self.klass is None: | |
412 | ## self.klass = attrVal | |
413 | ## if ce.tagtype == 'class' and attrName == 'sym_name' and self.sym_klass is None: | |
414 | ## self.sym_klass = attrVal | |
415 | ||
416 | ||
417 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'name': | |
418 | ## ## # save the elements name | |
419 | ## ## ce = self.elements[0] | |
420 | ## ## if ce.name is None: | |
421 | ## ## ce.name = attrs['value'] | |
422 | ## ## ce.nameLine = self.locator.getLineNumber() | |
423 | ||
424 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'sym_name': | |
425 | ## ## # save the elements name | |
426 | ## ## ce = self.elements[0] | |
427 | ## ## if ce.sym_name is None: | |
428 | ## ## ce.sym_name = attrs['value'] | |
429 | ||
430 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'decl': | |
431 | ## ## # save the elements decl | |
432 | ## ## ce = self.elements[0] | |
433 | ## ## ce.decl = attrs['value'] | |
434 | ||
435 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'feature_immutable': | |
436 | ## ## # save the elements decl | |
437 | ## ## ce = self.elements[0] | |
438 | ## ## ce.immutable = int(attrs['value']) | |
439 | ||
440 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'module': | |
441 | ## ## # save the elements decl | |
442 | ## ## ce = self.elements[0] | |
443 | ## ## ce.module = attrs['value'] | |
444 | ||
445 | ## elif name == 'import': | |
446 | ## self.imports += 1 | |
447 | ||
448 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'storage': | |
449 | ## ## # save the elements decl | |
450 | ## ## ce = self.elements[0] | |
451 | ## ## ce.storage = attrs['value'] | |
452 | ||
453 | ## ## elif len(self.elements) and name == 'attribute' and attrs['name'] == 'type': | |
454 | ## ## # save the elements decl | |
455 | ## ## ce = self.elements[0] | |
456 | ## ## ce.type = attrs['value'] | |
457 | ||
458 | ||
459 | ## def endElement(self, name): | |
460 | ## if name in interestingTypes: | |
461 | ## # end of an element that we are interested in | |
462 | ## ce = self.elements.pop(0) | |
463 | ||
464 | ## if self.imports == 0: | |
465 | ## # only write for items that are in this file, not imported | |
466 | ## ce.write(self.modname, self.swigFile, self.pyFile) | |
467 | ||
468 | ## if name == 'import': | |
469 | ## self.imports -= 1 | |
470 | ||
471 | ## if name == 'class': | |
472 | ## self.klass = None | |
473 | ## self.sym_klass = None | |
474 | ||
475 | ||
476 | #--------------------------------------------------------------------------- | |
1128a89b RD |
477 | #---------------------------------------------------------------------- |
478 | # flags and values that affect this script | |
479 | #---------------------------------------------------------------------- | |
480 | ||
481 | VER_MAJOR = 2 # The first three must match wxWidgets | |
482 | VER_MINOR = 5 | |
1eac708b | 483 | VER_RELEASE = 2 |
96acd0c1 RD |
484 | VER_SUBREL = 2 # wxPython release num for x.y.z release of wxWidgets |
485 | VER_FLAGS = "p" # release flags, such as prerelease num, unicode, etc. | |
1128a89b RD |
486 | |
487 | DESCRIPTION = "Cross platform GUI toolkit for Python" | |
488 | AUTHOR = "Robin Dunn" | |
489 | AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>" | |
490 | URL = "http://wxPython.org/" | |
491 | DOWNLOAD_URL = "http://wxPython.org/download.php" | |
492 | LICENSE = "wxWidgets Library License (LGPL derivative)" | |
493 | PLATFORMS = "WIN32,OSX,POSIX" | |
494 | KEYWORDS = "GUI,wx,wxWindows,wxWidgets,cross-platform" | |
495 | ||
496 | LONG_DESCRIPTION = """\ | |
497 | wxPython is a GUI toolkit for Python that is a wrapper around the | |
498 | wxWidgets C++ GUI library. wxPython provides a large variety of | |
499 | window types and controls, all implemented with a native look and | |
500 | feel (by using the native widgets) on the platforms it is supported | |
501 | on. | |
502 | """ | |
503 | ||
504 | CLASSIFIERS = """\ | |
505 | Development Status :: 6 - Mature | |
506 | Environment :: MacOS X :: Carbon | |
507 | Environment :: Win32 (MS Windows) | |
508 | Environment :: X11 Applications :: GTK | |
509 | Intended Audience :: Developers | |
510 | License :: OSI Approved | |
511 | Operating System :: MacOS :: MacOS X | |
512 | Operating System :: Microsoft :: Windows :: Windows 95/98/2000 | |
513 | Operating System :: POSIX | |
514 | Programming Language :: Python | |
515 | Topic :: Software Development :: User Interfaces | |
516 | """ | |
517 | ||
518 | ## License :: OSI Approved :: wxWidgets Library Licence | |
519 | ||
520 | ||
521 | # Config values below this point can be reset on the setup.py command line. | |
522 | ||
523 | BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module | |
524 | BUILD_OGL = 1 # If true, build the contrib/ogl extension module | |
525 | BUILD_STC = 1 # If true, build the contrib/stc extension module | |
526 | BUILD_XRC = 1 # XML based resource system | |
527 | BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library | |
528 | BUILD_DLLWIDGET = 0# Build a module that enables unknown wx widgets | |
529 | # to be loaded from a DLL and to be used from Python. | |
530 | ||
531 | # Internet Explorer wrapper (experimental) | |
532 | BUILD_IEWIN = (os.name == 'nt') | |
ef8b9c3e | 533 | BUILD_ACTIVEX = (os.name == 'nt') # new version of IEWIN and more |
1128a89b RD |
534 | |
535 | ||
536 | CORE_ONLY = 0 # if true, don't build any of the above | |
537 | ||
538 | PREP_ONLY = 0 # Only run the prepatory steps, not the actual build. | |
539 | ||
540 | USE_SWIG = 0 # Should we actually execute SWIG, or just use the | |
541 | # files already in the distribution? | |
542 | ||
543 | SWIG = "swig" # The swig executable to use. | |
544 | ||
545 | BUILD_RENAMERS = 1 # Should we build the renamer modules too? | |
546 | ||
d07d2bc9 RD |
547 | FULL_DOCS = 0 # Some docstrings are split into a basic docstring and a |
548 | # details string. Setting this flag to 1 will | |
549 | # cause the two strings to be combined and output | |
550 | # as the full docstring. | |
551 | ||
1128a89b RD |
552 | UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG and |
553 | # will ensure that the right headers are found and the | |
554 | # right libs are linked. | |
555 | ||
556 | UNDEF_NDEBUG = 1 # Python 2.2 on Unix/Linux by default defines NDEBUG, | |
557 | # and distutils will pick this up and use it on the | |
558 | # compile command-line for the extensions. This could | |
559 | # conflict with how wxWidgets was built. If NDEBUG is | |
560 | # set then wxWidgets' __WXDEBUG__ setting will be turned | |
561 | # off. If wxWidgets was actually built with it turned | |
562 | # on then you end up with mismatched class structures, | |
563 | # and wxPython will crash. | |
564 | ||
565 | NO_SCRIPTS = 0 # Don't install the tool scripts | |
566 | NO_HEADERS = 0 # Don't install the wxPython *.h and *.i files | |
567 | ||
568 | WX_CONFIG = None # Usually you shouldn't need to touch this, but you can set | |
569 | # it to pass an alternate version of wx-config or alternate | |
570 | # flags, eg. as required by the .deb in-tree build. By | |
571 | # default a wx-config command will be assembled based on | |
572 | # version, port, etc. and it will be looked for on the | |
573 | # default $PATH. | |
574 | ||
575 | WXPORT = 'gtk' # On Linux/Unix there are several ports of wxWidgets available. | |
576 | # Setting this value lets you select which will be used for | |
577 | # the wxPython build. Possibilites are 'gtk', 'gtk2' and | |
578 | # 'x11'. Curently only gtk and gtk2 works. | |
579 | ||
580 | BUILD_BASE = "build" # Directory to use for temporary build files. | |
581 | # This name will be appended to if the WXPORT or | |
582 | # the UNICODE flags are set to non-standard | |
583 | # values. See below. | |
584 | ||
585 | ||
586 | CONTRIBS_INC = "" # A dir to add as an -I flag when compiling the contribs | |
587 | ||
588 | ||
589 | # Some MSW build settings | |
590 | ||
591 | FINAL = 0 # Mirrors use of same flag in wx makefiles, | |
592 | # (0 or 1 only) should probably find a way to | |
593 | # autodetect this... | |
594 | ||
595 | HYBRID = 1 # If set and not debug or FINAL, then build a | |
596 | # hybrid extension that can be used by the | |
597 | # non-debug version of python, but contains | |
598 | # debugging symbols for wxWidgets and wxPython. | |
599 | # wxWidgets must have been built with /MD, not /MDd | |
600 | # (using FINAL=hybrid will do it.) | |
601 | ||
602 | # Version part of wxWidgets LIB/DLL names | |
603 | WXDLLVER = '%d%d' % (VER_MAJOR, VER_MINOR) | |
604 | ||
73a22369 RD |
605 | WXPY_SRC = '.' # Assume we're in the source tree already, but allow the |
606 | # user to change it, particularly for extension building. | |
607 | ||
1128a89b RD |
608 | |
609 | #---------------------------------------------------------------------- | |
610 | ||
611 | def msg(text): | |
fb3d05e9 | 612 | if hasattr(sys, 'setup_is_main') and sys.setup_is_main: |
1128a89b RD |
613 | print text |
614 | ||
615 | ||
616 | def opj(*args): | |
73a22369 | 617 | path = os.path.join(*args) |
1128a89b RD |
618 | return os.path.normpath(path) |
619 | ||
620 | ||
621 | def libFlag(): | |
622 | if FINAL: | |
623 | rv = '' | |
624 | elif HYBRID: | |
625 | rv = 'h' | |
626 | else: | |
627 | rv = 'd' | |
628 | if UNICODE: | |
629 | rv = 'u' + rv | |
630 | return rv | |
631 | ||
632 | ||
633 | #---------------------------------------------------------------------- | |
634 | # Some other globals | |
635 | #---------------------------------------------------------------------- | |
636 | ||
637 | PKGDIR = 'wx' | |
638 | wxpExtensions = [] | |
639 | DATA_FILES = [] | |
640 | CLEANUP = [] | |
641 | ||
642 | force = '--force' in sys.argv or '-f' in sys.argv | |
643 | debug = '--debug' in sys.argv or '-g' in sys.argv | |
644 | cleaning = 'clean' in sys.argv | |
645 | ||
646 | ||
647 | # change the PORT default for wxMac | |
648 | if sys.platform[:6] == "darwin": | |
649 | WXPORT = 'mac' | |
650 | ||
651 | # and do the same for wxMSW, just for consistency | |
652 | if os.name == 'nt': | |
653 | WXPORT = 'msw' | |
654 | ||
655 | ||
656 | #---------------------------------------------------------------------- | |
657 | # Check for build flags on the command line | |
658 | #---------------------------------------------------------------------- | |
659 | ||
660 | # Boolean (int) flags | |
661 | for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC', | |
662 | 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN', 'BUILD_ACTIVEX', | |
663 | 'CORE_ONLY', 'PREP_ONLY', 'USE_SWIG', 'UNICODE', | |
664 | 'UNDEF_NDEBUG', 'NO_SCRIPTS', 'NO_HEADERS', 'BUILD_RENAMERS', | |
d07d2bc9 | 665 | 'FULL_DOCS', |
1128a89b RD |
666 | 'FINAL', 'HYBRID', ]: |
667 | for x in range(len(sys.argv)): | |
668 | if sys.argv[x].find(flag) == 0: | |
669 | pos = sys.argv[x].find('=') + 1 | |
670 | if pos > 0: | |
671 | vars()[flag] = eval(sys.argv[x][pos:]) | |
672 | sys.argv[x] = '' | |
673 | ||
674 | # String options | |
675 | for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE', 'WXPORT', 'SWIG', | |
73a22369 | 676 | 'CONTRIBS_INC', 'WXPY_SRC']: |
1128a89b RD |
677 | for x in range(len(sys.argv)): |
678 | if sys.argv[x].find(option) == 0: | |
679 | pos = sys.argv[x].find('=') + 1 | |
680 | if pos > 0: | |
681 | vars()[option] = sys.argv[x][pos:] | |
682 | sys.argv[x] = '' | |
683 | ||
684 | sys.argv = filter(None, sys.argv) | |
685 | ||
686 | ||
687 | #---------------------------------------------------------------------- | |
688 | # some helper functions | |
689 | #---------------------------------------------------------------------- | |
690 | ||
691 | def Verify_WX_CONFIG(): | |
692 | """ Called below for the builds that need wx-config, | |
693 | if WX_CONFIG is not set then tries to select the specific | |
694 | wx*-config script based on build options. If not found | |
695 | then it defaults to 'wx-config'. | |
696 | """ | |
697 | # if WX_CONFIG hasn't been set to an explicit value then construct one. | |
698 | global WX_CONFIG | |
699 | if WX_CONFIG is None: | |
700 | if debug: # TODO: Fix this. wxPython's --debug shouldn't be tied to wxWidgets... | |
701 | df = 'd' | |
702 | else: | |
703 | df = '' | |
704 | if UNICODE: | |
705 | uf = 'u' | |
706 | else: | |
707 | uf = '' | |
708 | ver2 = "%s.%s" % (VER_MAJOR, VER_MINOR) | |
709 | port = WXPORT | |
710 | if port == "x11": | |
711 | port = "x11univ" | |
712 | WX_CONFIG = 'wx%s%s%s-%s-config' % (port, uf, df, ver2) | |
713 | ||
714 | searchpath = os.environ["PATH"] | |
715 | for p in searchpath.split(':'): | |
716 | fp = os.path.join(p, WX_CONFIG) | |
717 | if os.path.exists(fp) and os.access(fp, os.X_OK): | |
718 | # success | |
719 | msg("Found wx-config: " + fp) | |
720 | WX_CONFIG = fp | |
721 | break | |
722 | else: | |
723 | msg("WX_CONFIG not specified and %s not found on $PATH " | |
724 | "defaulting to \"wx-config\"" % WX_CONFIG) | |
725 | WX_CONFIG = 'wx-config' | |
726 | ||
727 | ||
728 | ||
54f9ee45 RD |
729 | def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, |
730 | swig_deps=[], add_under=False): | |
1128a89b RD |
731 | """Run SWIG the way I want it done""" |
732 | ||
733 | if USE_SWIG and not os.path.exists(os.path.join(dir, gendir)): | |
734 | os.mkdir(os.path.join(dir, gendir)) | |
735 | ||
736 | if USE_SWIG and not os.path.exists(os.path.join("docs", "xml-raw")): | |
73a22369 RD |
737 | if not os.path.exists("docs"): |
738 | os.mkdir("docs") | |
1128a89b RD |
739 | os.mkdir(os.path.join("docs", "xml-raw")) |
740 | ||
741 | sources = [] | |
742 | ||
54f9ee45 RD |
743 | if add_under: pre = '_' |
744 | else: pre = '' | |
745 | ||
1128a89b RD |
746 | for file in files: |
747 | basefile = os.path.splitext(file)[0] | |
748 | i_file = os.path.join(dir, file) | |
54f9ee45 RD |
749 | py_file = os.path.join(dir, gendir, pre+basefile+'.py') |
750 | cpp_file = os.path.join(dir, gendir, pre+basefile+'_wrap.cpp') | |
fda33067 | 751 | xml_file = os.path.join("docs", "xml-raw", basefile+pre+'_swig.xml') |
1128a89b | 752 | |
54f9ee45 RD |
753 | if add_under: |
754 | interface = ['-interface', '_'+basefile+'_'] | |
755 | else: | |
756 | interface = [] | |
757 | ||
1128a89b RD |
758 | sources.append(cpp_file) |
759 | ||
760 | if not cleaning and USE_SWIG: | |
761 | for dep in swig_deps: | |
762 | if newer(dep, py_file) or newer(dep, cpp_file): | |
763 | force = 1 | |
764 | break | |
765 | ||
766 | if force or newer(i_file, py_file) or newer(i_file, cpp_file): | |
767 | ## we need forward slashes here even on win32 | |
768 | #cpp_file = opj(cpp_file) #'/'.join(cpp_file.split('\\')) | |
769 | #i_file = opj(i_file) #'/'.join(i_file.split('\\')) | |
770 | ||
771 | if BUILD_RENAMERS: | |
1128a89b RD |
772 | xmltemp = tempfile.mktemp('.xml') |
773 | ||
774 | # First run swig to produce the XML file, adding | |
775 | # an extra -D that prevents the old rename | |
776 | # directives from being used | |
777 | cmd = [ swig_cmd ] + swig_args + \ | |
778 | [ '-DBUILDING_RENAMERS', '-xmlout', xmltemp ] + \ | |
779 | ['-I'+dir, '-o', cpp_file, i_file] | |
780 | msg(' '.join(cmd)) | |
781 | spawn(cmd) | |
782 | ||
783 | # Next run build_renamers to process the XML | |
73a22369 RD |
784 | myRenamer = BuildRenamers() |
785 | myRenamer.run(dir, pre+basefile, xmltemp) | |
1128a89b RD |
786 | os.remove(xmltemp) |
787 | ||
788 | # Then run swig for real | |
54f9ee45 RD |
789 | cmd = [ swig_cmd ] + swig_args + interface + \ |
790 | ['-I'+dir, '-o', cpp_file, '-xmlout', xml_file, i_file] | |
1128a89b RD |
791 | msg(' '.join(cmd)) |
792 | spawn(cmd) | |
793 | ||
794 | ||
795 | # copy the generated python file to the package directory | |
796 | copy_file(py_file, package, update=not force, verbose=0) | |
797 | CLEANUP.append(opj(package, os.path.basename(py_file))) | |
798 | ||
799 | return sources | |
800 | ||
801 | ||
802 | ||
803 | # Specializations of some distutils command classes | |
804 | class wx_smart_install_data(distutils.command.install_data.install_data): | |
805 | """need to change self.install_dir to the actual library dir""" | |
806 | def run(self): | |
807 | install_cmd = self.get_finalized_command('install') | |
808 | self.install_dir = getattr(install_cmd, 'install_lib') | |
809 | return distutils.command.install_data.install_data.run(self) | |
810 | ||
811 | ||
812 | class wx_extra_clean(distutils.command.clean.clean): | |
813 | """ | |
814 | Also cleans stuff that this setup.py copies itself. If the | |
815 | --all flag was used also searches for .pyc, .pyd, .so files | |
816 | """ | |
817 | def run(self): | |
818 | from distutils import log | |
819 | from distutils.filelist import FileList | |
820 | global CLEANUP | |
821 | ||
822 | distutils.command.clean.clean.run(self) | |
823 | ||
824 | if self.all: | |
825 | fl = FileList() | |
826 | fl.include_pattern("*.pyc", 0) | |
827 | fl.include_pattern("*.pyd", 0) | |
828 | fl.include_pattern("*.so", 0) | |
829 | CLEANUP += fl.files | |
830 | ||
831 | for f in CLEANUP: | |
832 | if os.path.isdir(f): | |
833 | try: | |
834 | if not self.dry_run and os.path.exists(f): | |
835 | os.rmdir(f) | |
836 | log.info("removing '%s'", f) | |
837 | except IOError: | |
838 | log.warning("unable to remove '%s'", f) | |
839 | ||
840 | else: | |
841 | try: | |
842 | if not self.dry_run and os.path.exists(f): | |
843 | os.remove(f) | |
844 | log.info("removing '%s'", f) | |
845 | except IOError: | |
846 | log.warning("unable to remove '%s'", f) | |
847 | ||
848 | ||
849 | ||
850 | class wx_install_headers(distutils.command.install_headers.install_headers): | |
851 | """ | |
852 | Install the header files to the WXPREFIX, with an extra dir per | |
853 | filename too | |
854 | """ | |
855 | def initialize_options (self): | |
856 | self.root = None | |
857 | distutils.command.install_headers.install_headers.initialize_options(self) | |
858 | ||
859 | def finalize_options (self): | |
860 | self.set_undefined_options('install', ('root', 'root')) | |
861 | distutils.command.install_headers.install_headers.finalize_options(self) | |
862 | ||
863 | def run(self): | |
864 | if os.name == 'nt': | |
865 | return | |
866 | headers = self.distribution.headers | |
867 | if not headers: | |
868 | return | |
869 | ||
870 | root = self.root | |
862b5362 | 871 | if root is None or WXPREFIX.startswith(root): |
1128a89b RD |
872 | root = '' |
873 | for header, location in headers: | |
874 | install_dir = os.path.normpath(root + WXPREFIX + location) | |
875 | self.mkpath(install_dir) | |
876 | (out, _) = self.copy_file(header, install_dir) | |
877 | self.outfiles.append(out) | |
878 | ||
879 | ||
880 | ||
881 | ||
882 | def build_locale_dir(destdir, verbose=1): | |
883 | """Build a locale dir under the wxPython package for MSW""" | |
884 | moFiles = glob.glob(opj(WXDIR, 'locale', '*.mo')) | |
885 | for src in moFiles: | |
886 | lang = os.path.splitext(os.path.basename(src))[0] | |
887 | dest = opj(destdir, lang, 'LC_MESSAGES') | |
888 | mkpath(dest, verbose=verbose) | |
889 | copy_file(src, opj(dest, 'wxstd.mo'), update=1, verbose=verbose) | |
890 | CLEANUP.append(opj(dest, 'wxstd.mo')) | |
891 | CLEANUP.append(dest) | |
892 | ||
893 | ||
894 | def build_locale_list(srcdir): | |
895 | # get a list of all files under the srcdir, to be used for install_data | |
896 | def walk_helper(lst, dirname, files): | |
897 | for f in files: | |
898 | filename = opj(dirname, f) | |
899 | if not os.path.isdir(filename): | |
900 | lst.append( (dirname, [filename]) ) | |
901 | file_list = [] | |
902 | os.path.walk(srcdir, walk_helper, file_list) | |
903 | return file_list | |
904 | ||
905 | ||
906 | def find_data_files(srcdir, *wildcards): | |
907 | # get a list of all files under the srcdir matching wildcards, | |
908 | # returned in a format to be used for install_data | |
909 | ||
910 | def walk_helper(arg, dirname, files): | |
911 | names = [] | |
912 | lst, wildcards = arg | |
913 | for wc in wildcards: | |
914 | for f in files: | |
915 | filename = opj(dirname, f) | |
916 | if fnmatch.fnmatch(filename, wc) and not os.path.isdir(filename): | |
917 | names.append(filename) | |
918 | if names: | |
919 | lst.append( (dirname, names ) ) | |
920 | ||
921 | file_list = [] | |
922 | os.path.walk(srcdir, walk_helper, (file_list, wildcards)) | |
923 | return file_list | |
924 | ||
925 | ||
926 | def makeLibName(name): | |
927 | if os.name == 'posix': | |
928 | libname = '%s_%s-%s' % (WXBASENAME, name, WXRELEASE) | |
929 | else: | |
930 | libname = 'wxmsw%s%s_%s' % (WXDLLVER, libFlag(), name) | |
931 | ||
932 | return [libname] | |
933 | ||
934 | ||
935 | ||
936 | def adjustCFLAGS(cflags, defines, includes): | |
937 | '''Extrace the raw -I, -D, and -U flags and put them into | |
938 | defines and includes as needed.''' | |
939 | newCFLAGS = [] | |
940 | for flag in cflags: | |
941 | if flag[:2] == '-I': | |
942 | includes.append(flag[2:]) | |
943 | elif flag[:2] == '-D': | |
944 | flag = flag[2:] | |
945 | if flag.find('=') == -1: | |
946 | defines.append( (flag, None) ) | |
947 | else: | |
948 | defines.append( tuple(flag.split('=')) ) | |
949 | elif flag[:2] == '-U': | |
950 | defines.append( (flag[2:], ) ) | |
951 | else: | |
952 | newCFLAGS.append(flag) | |
953 | return newCFLAGS | |
954 | ||
955 | ||
956 | ||
957 | def adjustLFLAGS(lfags, libdirs, libs): | |
958 | '''Extrace the -L and -l flags and put them in libdirs and libs as needed''' | |
959 | newLFLAGS = [] | |
960 | for flag in lflags: | |
961 | if flag[:2] == '-L': | |
962 | libdirs.append(flag[2:]) | |
963 | elif flag[:2] == '-l': | |
964 | libs.append(flag[2:]) | |
965 | else: | |
966 | newLFLAGS.append(flag) | |
967 | ||
968 | return newLFLAGS | |
969 | ||
970 | #---------------------------------------------------------------------- | |
971 | # sanity checks | |
972 | ||
973 | if CORE_ONLY: | |
974 | BUILD_GLCANVAS = 0 | |
975 | BUILD_OGL = 0 | |
976 | BUILD_STC = 0 | |
977 | BUILD_XRC = 0 | |
978 | BUILD_GIZMOS = 0 | |
979 | BUILD_DLLWIDGET = 0 | |
980 | BUILD_IEWIN = 0 | |
981 | BUILD_ACTIVEX = 0 | |
982 | ||
983 | if debug: | |
984 | FINAL = 0 | |
985 | HYBRID = 0 | |
986 | ||
987 | if FINAL: | |
988 | HYBRID = 0 | |
989 | ||
990 | if UNICODE and WXPORT not in ['msw', 'gtk2']: | |
991 | raise SystemExit, "UNICODE mode not currently supported on this WXPORT: "+WXPORT | |
992 | ||
993 | ||
994 | if CONTRIBS_INC: | |
995 | CONTRIBS_INC = [ CONTRIBS_INC ] | |
996 | else: | |
997 | CONTRIBS_INC = [] | |
998 | ||
999 | ||
1000 | #---------------------------------------------------------------------- | |
1001 | # Setup some platform specific stuff | |
1002 | #---------------------------------------------------------------------- | |
1003 | ||
1004 | if os.name == 'nt': | |
1005 | # Set compile flags and such for MSVC. These values are derived | |
1006 | # from the wxWidgets makefiles for MSVC, other compilers settings | |
1007 | # will probably vary... | |
1008 | if os.environ.has_key('WXWIN'): | |
1009 | WXDIR = os.environ['WXWIN'] | |
1010 | else: | |
1011 | msg("WARNING: WXWIN not set in environment.") | |
1012 | WXDIR = '..' # assumes in CVS tree | |
1013 | WXPLAT = '__WXMSW__' | |
1014 | GENDIR = 'msw' | |
1015 | ||
1016 | includes = ['include', 'src', | |
1017 | opj(WXDIR, 'lib', 'vc_dll', 'msw' + libFlag()), | |
1018 | opj(WXDIR, 'include'), | |
1019 | opj(WXDIR, 'contrib', 'include'), | |
1020 | ] | |
1021 | ||
1022 | defines = [ ('WIN32', None), | |
1023 | ('_WINDOWS', None), | |
1024 | ||
1025 | (WXPLAT, None), | |
1026 | ('WXUSINGDLL', '1'), | |
1027 | ||
1028 | ('SWIG_GLOBAL', None), | |
1029 | ('WXP_USE_THREAD', '1'), | |
1030 | ] | |
1031 | ||
1032 | if UNDEF_NDEBUG: | |
1033 | defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef | |
1034 | ||
1035 | if HYBRID: | |
1036 | defines.append( ('__NO_VC_CRTDBG__', None) ) | |
1037 | ||
1038 | if not FINAL or HYBRID: | |
1039 | defines.append( ('__WXDEBUG__', None) ) | |
1040 | ||
1041 | libdirs = [ opj(WXDIR, 'lib', 'vc_dll') ] | |
1042 | libs = [ 'wxbase' + WXDLLVER + libFlag(), # TODO: trim this down to what is really needed for the core | |
1043 | 'wxbase' + WXDLLVER + libFlag() + '_net', | |
1044 | 'wxbase' + WXDLLVER + libFlag() + '_xml', | |
1045 | makeLibName('core')[0], | |
1046 | makeLibName('adv')[0], | |
1047 | makeLibName('html')[0], | |
1048 | ] | |
1049 | ||
1050 | libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32', | |
1051 | 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32', | |
1052 | 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4', | |
1053 | 'advapi32', 'wsock32'] | |
1054 | ||
1055 | ||
1056 | cflags = [ '/Gy', | |
1057 | # '/GX-' # workaround for internal compiler error in MSVC on some machines | |
1058 | ] | |
1059 | lflags = None | |
1060 | ||
1061 | # Other MSVC flags... | |
1062 | # Too bad I don't remember why I was playing with these, can they be removed? | |
1063 | if FINAL: | |
1064 | pass #cflags = cflags + ['/O1'] | |
1065 | elif HYBRID : | |
1066 | pass #cflags = cflags + ['/Ox'] | |
1067 | else: | |
1068 | pass # cflags = cflags + ['/Od', '/Z7'] | |
1069 | # lflags = ['/DEBUG', ] | |
1070 | ||
1071 | ||
1072 | ||
1073 | #---------------------------------------------------------------------- | |
1074 | ||
1075 | elif os.name == 'posix': | |
1076 | WXDIR = '..' | |
1077 | includes = ['include', 'src'] | |
1078 | defines = [('SWIG_GLOBAL', None), | |
1079 | ('HAVE_CONFIG_H', None), | |
1080 | ('WXP_USE_THREAD', '1'), | |
1081 | ] | |
1082 | if UNDEF_NDEBUG: | |
1083 | defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef | |
1084 | ||
1085 | Verify_WX_CONFIG() | |
1086 | ||
1087 | libdirs = [] | |
1088 | libs = [] | |
1089 | ||
1090 | # If you get unresolved symbol errors on Solaris and are using gcc, then | |
1091 | # uncomment this block to add the right flags to the link step and build | |
1092 | # again. | |
1093 | ## if os.uname()[0] == 'SunOS': | |
1094 | ## libs.append('gcc') | |
1095 | ## libdirs.append(commands.getoutput("gcc -print-search-dirs | grep '^install' | awk '{print $2}'")[:-1]) | |
1096 | ||
1097 | cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1] | |
1098 | cflags = cflags.split() | |
1099 | if debug: | |
1100 | cflags.append('-g') | |
1101 | cflags.append('-O0') | |
1102 | else: | |
1103 | cflags.append('-O3') | |
1104 | ||
1105 | lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1] | |
1106 | lflags = lflags.split() | |
1107 | ||
1108 | WXBASENAME = os.popen(WX_CONFIG + ' --basename').read()[:-1] | |
1109 | WXRELEASE = os.popen(WX_CONFIG + ' --release').read()[:-1] | |
1110 | WXPREFIX = os.popen(WX_CONFIG + ' --prefix').read()[:-1] | |
1111 | ||
1112 | ||
1113 | if sys.platform[:6] == "darwin": | |
1114 | # Flags and such for a Darwin (Max OS X) build of Python | |
1115 | WXPLAT = '__WXMAC__' | |
1116 | GENDIR = 'mac' | |
1117 | libs = ['stdc++'] | |
1118 | NO_SCRIPTS = 1 | |
1119 | ||
1120 | ||
1121 | else: | |
1122 | # Set flags for other Unix type platforms | |
1123 | GENDIR = WXPORT | |
1124 | ||
1125 | if WXPORT == 'gtk': | |
1126 | WXPLAT = '__WXGTK__' | |
1127 | portcfg = os.popen('gtk-config --cflags', 'r').read()[:-1] | |
1128 | elif WXPORT == 'gtk2': | |
1129 | WXPLAT = '__WXGTK__' | |
1130 | GENDIR = 'gtk' # no code differences so use the same generated sources | |
1131 | portcfg = os.popen('pkg-config gtk+-2.0 --cflags', 'r').read()[:-1] | |
1132 | BUILD_BASE = BUILD_BASE + '-' + WXPORT | |
1133 | elif WXPORT == 'x11': | |
1134 | WXPLAT = '__WXX11__' | |
1135 | portcfg = '' | |
1136 | BUILD_BASE = BUILD_BASE + '-' + WXPORT | |
1137 | else: | |
1138 | raise SystemExit, "Unknown WXPORT value: " + WXPORT | |
1139 | ||
1140 | cflags += portcfg.split() | |
1141 | ||
1142 | # Some distros (e.g. Mandrake) put libGLU in /usr/X11R6/lib, but | |
1143 | # wx-config doesn't output that for some reason. For now, just | |
1144 | # add it unconditionally but we should really check if the lib is | |
1145 | # really found there or wx-config should be fixed. | |
1146 | libdirs.append("/usr/X11R6/lib") | |
1147 | ||
1148 | ||
1149 | # Move the various -I, -D, etc. flags we got from the *config scripts | |
1150 | # into the distutils lists. | |
1151 | cflags = adjustCFLAGS(cflags, defines, includes) | |
1152 | lflags = adjustLFLAGS(lflags, libdirs, libs) | |
1153 | ||
1154 | ||
1155 | #---------------------------------------------------------------------- | |
1156 | else: | |
1157 | raise 'Sorry, platform not supported...' | |
1158 | ||
1159 | ||
1160 | #---------------------------------------------------------------------- | |
1161 | # post platform setup checks and tweaks, create the full version string | |
1162 | #---------------------------------------------------------------------- | |
1163 | ||
1164 | if UNICODE: | |
1165 | BUILD_BASE = BUILD_BASE + '.unicode' | |
1166 | VER_FLAGS += 'u' | |
1167 | ||
96acd0c1 | 1168 | if os.path.exists('DAILY_BUILD'): |
4b2826e5 RD |
1169 | |
1170 | VER_FLAGS += '.' + open('DAILY_BUILD').read().strip() | |
1128a89b RD |
1171 | |
1172 | VERSION = "%s.%s.%s.%s%s" % (VER_MAJOR, VER_MINOR, VER_RELEASE, | |
1173 | VER_SUBREL, VER_FLAGS) | |
1174 | ||
1175 | ||
1176 | #---------------------------------------------------------------------- | |
1177 | # SWIG defaults | |
1178 | #---------------------------------------------------------------------- | |
1179 | ||
1180 | swig_cmd = SWIG | |
1181 | swig_force = force | |
1182 | swig_args = ['-c++', | |
1183 | '-Wall', | |
1184 | '-nodefault', | |
1185 | ||
1186 | '-python', | |
1187 | '-keyword', | |
1188 | '-new_repr', | |
1189 | '-modern', | |
1190 | ||
73a22369 | 1191 | '-I' + opj(WXPY_SRC, 'src'), |
1128a89b RD |
1192 | '-D'+WXPLAT, |
1193 | '-noruntime' | |
1194 | ] | |
1195 | if UNICODE: | |
1196 | swig_args.append('-DwxUSE_UNICODE') | |
1197 | ||
d07d2bc9 RD |
1198 | if FULL_DOCS: |
1199 | swig_args.append('-D_DO_FULL_DOCS') | |
1200 | ||
1201 | ||
73a22369 RD |
1202 | swig_deps = [ opj(WXPY_SRC, 'src/my_typemaps.i'), |
1203 | opj(WXPY_SRC, 'src/common.swg'), | |
1204 | opj(WXPY_SRC, 'src/pyrun.swg'), | |
1128a89b RD |
1205 | ] |
1206 | ||
1207 | depends = [ #'include/wx/wxPython/wxPython.h', | |
1208 | #'include/wx/wxPython/wxPython_int.h', | |
1209 | #'src/pyclasses.h', | |
1210 | ] | |
1211 | ||
1212 | #---------------------------------------------------------------------- |