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