]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
Calling a virtual function from a destructor is not good:
[wxWidgets.git] / wxPython / setup.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------
3
4 import sys, os, glob
5 from distutils.core import setup, Extension
6 from distutils.file_util import copy_file
7 from distutils.dir_util import mkpath
8 from distutils.dep_util import newer
9 from distutils.spawn import spawn
10 from distutils.command.install_data import install_data
11
12 #----------------------------------------------------------------------
13 # flags and values that affect this script
14 #----------------------------------------------------------------------
15
16 VERSION = "2.5.0p1"
17 DESCRIPTION = "Cross platform GUI toolkit for Python"
18 AUTHOR = "Robin Dunn"
19 AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>"
20 URL = "http://wxPython.org/"
21 LICENSE = "wxWindows (LGPL derivative)"
22 LONG_DESCRIPTION = """\
23 wxPython is a GUI toolkit for Python that is a wrapper around the
24 wxWindows C++ GUI library. wxPython provides a large variety of
25 window types and controls, all implemented with a native look and
26 feel (by using the native widgets) on the platforms it is supported
27 on.
28 """
29
30
31 # Config values below this point can be reset on the setup.py command line.
32
33 BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module
34 BUILD_OGL = 1 # If true, build the contrib/ogl extension module
35 BUILD_STC = 1 # If true, build the contrib/stc extension module
36 BUILD_XRC = 1 # XML based resource system
37 BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library
38 BUILD_DLLWIDGET = 0# Build a module that enables unknown wx widgets
39 # to be loaded from a DLL and to be used from Python.
40
41 # Internet Explorer wrapper (experimental)
42 BUILD_IEWIN = (os.name == 'nt')
43
44 BUILD_CANVAS = 0 # Build a canvas module using the one in wx/contrib (experimental)
45 BUILD_ART2D = 0 # Build a canvas module using code from the wxArt2D project (experimental)
46
47
48 CORE_ONLY = 0 # if true, don't build any of the above
49
50 PREP_ONLY = 0 # Only run the prepatory steps, not the actual build.
51
52 USE_SWIG = 0 # Should we actually execute SWIG, or just use the
53 # files already in the distribution?
54
55 UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG and
56 # will ensure that the right headers are found and the
57 # right libs are linked.
58
59 IN_CVS_TREE = 1 # Set to true if building in a full wxWindows CVS
60 # tree, or the new style of a full wxPythonSrc tarball.
61 # wxPython used to be distributed as a separate source
62 # tarball without the wxWindows but with a copy of the
63 # needed contrib code. That's no longer the case and so
64 # this setting is now defaulting to true. Eventually it
65 # should be removed entirly.
66
67 UNDEF_NDEBUG = 1 # Python 2.2 on Unix/Linux by default defines NDEBUG,
68 # and distutils will pick this up and use it on the
69 # compile command-line for the extensions. This could
70 # conflict with how wxWindows was built. If NDEBUG is
71 # set then wxWindows' __WXDEBUG__ setting will be turned
72 # off. If wxWindows was actually built with it turned
73 # on then you end up with mismatched class structures,
74 # and wxPython will crash.
75
76 NO_SCRIPTS = 0 # Don't install the tool scripts
77
78 WX_CONFIG = None # Usually you shouldn't need to touch this, but you can set
79 # it to pass an alternate version of wx-config or alternate
80 # flags, eg. as required by the .deb in-tree build. By
81 # default a wx-config command will be assembled based on
82 # version, port, etc. and it will be looked for on the
83 # default $PATH.
84
85 WXPORT = 'gtk' # On Linux/Unix there are several ports of wxWindows available.
86 # Setting this value lets you select which will be used for
87 # the wxPython build. Possibilites are 'gtk', 'gtk2' and
88 # 'x11'. Curently only gtk and gtk2 works.
89
90 BUILD_BASE = "build" # Directory to use for temporary build files.
91
92
93
94 # Some MSW build settings
95
96 FINAL = 0 # Mirrors use of same flag in wx makefiles,
97 # (0 or 1 only) should probably find a way to
98 # autodetect this...
99
100 HYBRID = 1 # If set and not debug or FINAL, then build a
101 # hybrid extension that can be used by the
102 # non-debug version of python, but contains
103 # debugging symbols for wxWindows and wxPython.
104 # wxWindows must have been built with /MD, not /MDd
105 # (using FINAL=hybrid will do it.)
106
107 WXDLLVER = '250' # Version part of wxWindows DLL name
108
109
110 #----------------------------------------------------------------------
111
112 def msg(text):
113 if __name__ == "__main__":
114 print text
115
116
117 def opj(*args):
118 path = apply(os.path.join, args)
119 return os.path.normpath(path)
120
121
122 def libFlag():
123 if FINAL:
124 rv = ''
125 elif HYBRID:
126 rv = 'h'
127 else:
128 rv = 'd'
129 if UNICODE:
130 rv = 'u' + rv
131 return rv
132
133
134 #----------------------------------------------------------------------
135 # Some other globals
136 #----------------------------------------------------------------------
137
138 PKGDIR = 'wxPython'
139 wxpExtensions = []
140 DATA_FILES = []
141
142 force = '--force' in sys.argv or '-f' in sys.argv
143 debug = '--debug' in sys.argv or '-g' in sys.argv
144
145 # change the PORT default for wxMac
146 if sys.platform[:6] == "darwin":
147 WXPORT = 'mac'
148
149 # and do the same for wxMSW, just for consistency
150 if os.name == 'nt':
151 WXPORT = 'msw'
152
153
154 #----------------------------------------------------------------------
155 # Check for build flags on the command line
156 #----------------------------------------------------------------------
157
158 # Boolean (int) flags
159 for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC',
160 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN',
161 'CORE_ONLY', 'PREP_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'UNICODE',
162 'UNDEF_NDEBUG', 'NO_SCRIPTS',
163 'FINAL', 'HYBRID', ]:
164 for x in range(len(sys.argv)):
165 if sys.argv[x].find(flag) == 0:
166 pos = sys.argv[x].find('=') + 1
167 if pos > 0:
168 vars()[flag] = eval(sys.argv[x][pos:])
169 sys.argv[x] = ''
170
171 # String options
172 for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE', 'WXPORT']:
173 for x in range(len(sys.argv)):
174 if sys.argv[x].find(option) == 0:
175 pos = sys.argv[x].find('=') + 1
176 if pos > 0:
177 vars()[option] = sys.argv[x][pos:]
178 sys.argv[x] = ''
179
180 sys.argv = filter(None, sys.argv)
181
182
183 #----------------------------------------------------------------------
184 # some helper functions
185 #----------------------------------------------------------------------
186
187 def Verify_WX_CONFIG():
188 """ Called below for the builds that need wx-config,
189 if WX_CONFIG is not set then tries to select the specific
190 wx*-config script based on build options. If not found
191 then it defaults to 'wx-config'.
192 """
193 # if WX_CONFIG hasn't been set to an explicit value then construct one.
194 global WX_CONFIG
195 if WX_CONFIG is None:
196 if debug: # TODO: Fix this. wxPython's --debug shouldn't be tied to wxWindows...
197 df = 'd'
198 else:
199 df = ''
200 if UNICODE:
201 uf = 'u'
202 else:
203 uf = ''
204 ver2 = VERSION[:3]
205 WX_CONFIG = 'wx%s%s%s-%s-config' % (WXPORT, uf, df, ver2)
206
207 searchpath = os.environ["PATH"]
208 for p in searchpath.split(':'):
209 fp = os.path.join(p, WX_CONFIG)
210 if os.path.exists(fp) and os.access(fp, os.X_OK):
211 # success
212 msg("Found wx-config: " + fp)
213 WX_CONFIG = fp
214 break
215 else:
216 msg("WX_CONFIG not specified and %s not found on $PATH "
217 "defaulting to \"wx-config\"" % WX_CONFIG)
218 WX_CONFIG = 'wx-config'
219
220
221
222 def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps=[]):
223 """Run SWIG the way I want it done"""
224 if not os.path.exists(os.path.join(dir, gendir)):
225 os.mkdir(os.path.join(dir, gendir))
226
227 sources = []
228
229 for file in files:
230 basefile = os.path.splitext(file)[0]
231 i_file = os.path.join(dir, file)
232 py_file = os.path.join(dir, gendir, basefile+'.py')
233 cpp_file = os.path.join(dir, gendir, basefile+'.cpp')
234
235 sources.append(cpp_file)
236
237 if USE_SWIG:
238 for dep in swig_deps:
239 if newer(dep, py_file) or newer(dep, cpp_file):
240 force = 1
241 break
242
243 if force or newer(i_file, py_file) or newer(i_file, cpp_file):
244 # we need forward slashes here even on win32
245 cpp_file = '/'.join(cpp_file.split('\\'))
246 i_file = '/'.join(i_file.split('\\'))
247
248 cmd = ['./wxSWIG/wxswig'] + swig_args + ['-I'+dir, '-c', '-o', cpp_file, i_file]
249 msg(' '.join(cmd))
250 spawn(cmd)
251
252 # copy the generated python file to the package directory
253 copy_file(py_file, package, update=not force, verbose=0)
254
255 return sources
256
257
258
259 def contrib_copy_tree(src, dest, verbose=0):
260 """Update local copies of wxWindows contrib files"""
261 from distutils.dir_util import mkpath, copy_tree
262
263 mkpath(dest, verbose=verbose)
264 copy_tree(src, dest, update=1, verbose=verbose)
265
266
267
268 class smart_install_data(install_data):
269 def run(self):
270 #need to change self.install_dir to the actual library dir
271 install_cmd = self.get_finalized_command('install')
272 self.install_dir = getattr(install_cmd, 'install_lib')
273 return install_data.run(self)
274
275
276 def build_locale_dir(destdir, verbose=1):
277 """Build a locale dir under the wxPython package for MSW"""
278 moFiles = glob.glob(opj(WXDIR, 'locale', '*.mo'))
279 for src in moFiles:
280 lang = os.path.splitext(os.path.basename(src))[0]
281 dest = opj(destdir, lang, 'LC_MESSAGES')
282 mkpath(dest, verbose=verbose)
283 copy_file(src, opj(dest, 'wxstd.mo'), update=1, verbose=verbose)
284
285
286 def build_locale_list(srcdir):
287 # get a list of all files under the srcdir, to be used for install_data
288 def walk_helper(lst, dirname, files):
289 for f in files:
290 filename = opj(dirname, f)
291 if not os.path.isdir(filename):
292 lst.append( (dirname, [filename]) )
293 file_list = []
294 os.path.walk(srcdir, walk_helper, file_list)
295 return file_list
296
297
298
299
300
301 #----------------------------------------------------------------------
302 # sanity checks
303
304 if CORE_ONLY:
305 BUILD_GLCANVAS = 0
306 BUILD_OGL = 0
307 BUILD_STC = 0
308 BUILD_XRC = 0
309 BUILD_GIZMOS = 0
310 BUILD_DLLWIDGET = 0
311 BUILD_IEWIN = 0
312
313 if debug:
314 FINAL = 0
315 HYBRID = 0
316
317 if FINAL:
318 HYBRID = 0
319
320 if UNICODE and WXPORT not in ['msw', 'gtk2']:
321 raise SystemExit, "UNICODE mode not currently supported on this WXPORT: "+WXPORT
322
323
324 #----------------------------------------------------------------------
325 # Setup some platform specific stuff
326 #----------------------------------------------------------------------
327
328 if os.name == 'nt':
329 # Set compile flags and such for MSVC. These values are derived
330 # from the wxWindows makefiles for MSVC, other compilers settings
331 # will probably vary...
332 if os.environ.has_key('WXWIN'):
333 WXDIR = os.environ['WXWIN']
334 else:
335 msg("WARNING: WXWIN not set in environment.")
336 WXDIR = '..' # assumes in CVS tree
337 WXPLAT = '__WXMSW__'
338 GENDIR = 'msw'
339
340 includes = ['src',
341 opj(WXDIR, 'lib', 'mswdll' + libFlag()),
342 opj(WXDIR, 'include'),
343 ]
344
345 defines = [ ('WIN32', None),
346 ('__WIN32__', None),
347 ('_WINDOWS', None),
348 ('__WINDOWS__', None),
349 ('WINVER', '0x0400'),
350 ('__WIN95__', None),
351 ('STRICT', None),
352
353 (WXPLAT, None),
354 ('WXUSINGDLL', '1'),
355
356 ('SWIG_GLOBAL', None),
357 ('HAVE_CONFIG_H', None),
358 ('WXP_USE_THREAD', '1'),
359 ]
360
361 if UNDEF_NDEBUG:
362 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
363
364
365 if not FINAL or HYBRID:
366 defines.append( ('__WXDEBUG__', None) )
367
368 libdirs = [ opj(WXDIR, 'lib') ]
369 wxdll = 'wxmsw' + WXDLLVER + libFlag()
370 libs = [ wxdll ]
371
372 libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
373 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
374 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
375 'advapi32', 'wsock32']
376
377
378 cflags = [ '/Gy',
379 # '/GX-' # workaround for internal compiler error in MSVC on some machines
380 ]
381 lflags = None
382
383 # Other MSVC flags...
384 # To bad I don't remember why I was playing with these, can they be removed?
385 if FINAL:
386 pass #cflags = cflags + ['/O1']
387 elif HYBRID :
388 pass #cflags = cflags + ['/Ox']
389 else:
390 pass # cflags = cflags + ['/Od', '/Z7']
391 # lflags = ['/DEBUG', ]
392
393
394
395 #----------------------------------------------------------------------
396
397 elif os.name == 'posix' and sys.platform[:6] == "darwin":
398 # Flags and such for a Darwin (Max OS X) build of Python
399 WXDIR = '..' # assumes IN_CVS_TREE
400 WXPLAT = '__WXMAC__'
401 GENDIR = 'mac'
402
403 includes = ['src']
404 defines = [('SWIG_GLOBAL', None),
405 ('HAVE_CONFIG_H', None),
406 ('WXP_USE_THREAD', '1'),
407 ]
408 if UNDEF_NDEBUG:
409 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
410 libdirs = []
411 libs = ['stdc++']
412
413 Verify_WX_CONFIG()
414
415 cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1]
416 cflags = cflags.split()
417 if debug:
418 cflags.append('-g')
419 cflags.append('-O0')
420
421 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
422 lflags = lflags.split()
423
424 NO_SCRIPTS = 1
425
426
427 #----------------------------------------------------------------------
428
429 elif os.name == 'posix':
430 # Set flags for other Unix type platforms
431 WXDIR = '..' # assumes IN_CVS_TREE
432 GENDIR = WXPORT
433
434 if WXPORT == 'gtk':
435 WXPLAT = '__WXGTK__'
436 portcfg = os.popen('gtk-config --cflags', 'r').read()[:-1]
437 elif WXPORT == 'gtk2':
438 WXPLAT = '__WXGTK__'
439 GENDIR = 'gtk' # no code differences so use the same generated sources
440 portcfg = os.popen('pkg-config gtk+-2.0 --cflags', 'r').read()[:-1]
441 BUILD_BASE = BUILD_BASE + '-' + WXPORT
442 elif WXPORT == 'x11':
443 WXPLAT = '__WXX11__'
444 portcfg = ''
445 BUILD_BASE = BUILD_BASE + '-' + WXPORT
446 else:
447 raise SystemExit, "Unknown WXPORT value: " + WXPORT
448
449 includes = ['src']
450 defines = [('SWIG_GLOBAL', None),
451 ('HAVE_CONFIG_H', None),
452 ('WXP_USE_THREAD', '1'),
453 ]
454 if UNDEF_NDEBUG:
455 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
456
457 libdirs = []
458 libs = []
459
460 Verify_WX_CONFIG()
461
462 cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1] + ' ' + portcfg
463
464 cflags = cflags.split()
465 if debug:
466 cflags.append('-g')
467 cflags.append('-O0')
468
469 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
470 lflags = lflags.split()
471
472 # Some distros (e.g. Mandrake) put libGLU in /usr/X11R6/lib, but
473 # wx-config doesn't output that for some reason. For now, just
474 # add it unconditionally but we should really check if the lib is
475 # really found there or wx-config should be fixed.
476 libdirs.append("/usr/X11R6/lib")
477
478
479 #----------------------------------------------------------------------
480 else:
481 raise 'Sorry Charlie, platform not supported...'
482
483
484 #----------------------------------------------------------------------
485 # post platform setup checks and tweaks
486 #----------------------------------------------------------------------
487
488 if UNICODE:
489 BUILD_BASE = BUILD_BASE + '.unicode'
490 VERSION = VERSION + 'u'
491
492
493 #----------------------------------------------------------------------
494 # Check if the version file needs updated
495 #----------------------------------------------------------------------
496
497 ##if IN_CVS_TREE and newer('setup.py', 'src/__version__.py'):
498
499 # Always do it since the version string can change based on the UNICODE flag
500 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION)
501
502
503
504 #----------------------------------------------------------------------
505 # SWIG defaults
506 #----------------------------------------------------------------------
507
508 swig_force = force
509 swig_args = ['-c++', '-shadow', '-python', '-keyword',
510 '-dnone',
511 #'-dascii',
512 #'-docstring', '-Sbefore',
513 '-I./src', '-D'+WXPLAT,
514 ]
515 if UNICODE:
516 swig_args.append('-DwxUSE_UNICODE')
517
518 swig_deps = ['src/my_typemaps.i']
519
520
521 #----------------------------------------------------------------------
522 # Define the CORE extension module
523 #----------------------------------------------------------------------
524
525 msg('Preparing CORE...')
526 swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
527 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
528 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
529 'printfw.i', 'sizers.i', 'clip_dnd.i',
530 'filesys.i', 'streams.i', 'utils.i', 'fonts.i'
531 ]
532
533 swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
534 USE_SWIG, swig_force, swig_args, swig_deps)
535
536 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
537 copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
538
539
540 if IN_CVS_TREE: # update the license files
541 mkpath('licence')
542 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
543 copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0)
544
545
546 if os.name == 'nt':
547 build_locale_dir(opj(PKGDIR, 'locale'))
548 DATA_FILES += build_locale_list(opj(PKGDIR, 'locale'))
549
550
551 if os.name == 'nt':
552 rc_file = ['src/wxc.rc']
553 else:
554 rc_file = []
555
556
557 ext = Extension('wxc', ['src/helpers.cpp',
558 'src/drawlist.cpp',
559 'src/libpy.c',
560 ] + rc_file + swig_sources,
561
562 include_dirs = includes,
563 define_macros = defines,
564
565 library_dirs = libdirs,
566 libraries = libs,
567
568 extra_compile_args = cflags,
569 extra_link_args = lflags,
570 )
571 wxpExtensions.append(ext)
572
573
574 # Extension for the grid module
575 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
576 USE_SWIG, swig_force, swig_args, swig_deps)
577 ext = Extension('gridc', swig_sources,
578 include_dirs = includes,
579 define_macros = defines,
580 library_dirs = libdirs,
581 libraries = libs,
582 extra_compile_args = cflags,
583 extra_link_args = lflags,
584 )
585 wxpExtensions.append(ext)
586
587
588 # Extension for the html modules
589 swig_sources = run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR, PKGDIR,
590 USE_SWIG, swig_force, swig_args, swig_deps)
591 ext = Extension('htmlc', swig_sources,
592 include_dirs = includes,
593 define_macros = defines,
594 library_dirs = libdirs,
595 libraries = libs,
596 extra_compile_args = cflags,
597 extra_link_args = lflags,
598 )
599 wxpExtensions.append(ext)
600
601
602 # Extension for the calendar module
603 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
604 USE_SWIG, swig_force, swig_args, swig_deps)
605 ext = Extension('calendarc', swig_sources,
606 include_dirs = includes,
607 define_macros = defines,
608 library_dirs = libdirs,
609 libraries = libs,
610 extra_compile_args = cflags,
611 extra_link_args = lflags,
612 )
613 wxpExtensions.append(ext)
614
615
616 # Extension for the help module
617 swig_sources = run_swig(['help.i'], 'src', GENDIR, PKGDIR,
618 USE_SWIG, swig_force, swig_args, swig_deps)
619 ext = Extension('helpc', swig_sources,
620 include_dirs = includes,
621 define_macros = defines,
622 library_dirs = libdirs,
623 libraries = libs,
624 extra_compile_args = cflags,
625 extra_link_args = lflags,
626 )
627 wxpExtensions.append(ext)
628
629
630 # Extension for the wizard module
631 swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR,
632 USE_SWIG, swig_force, swig_args, swig_deps)
633 ext = Extension('wizardc', swig_sources,
634 include_dirs = includes,
635 define_macros = defines,
636 library_dirs = libdirs,
637 libraries = libs,
638 extra_compile_args = cflags,
639 extra_link_args = lflags,
640 )
641 wxpExtensions.append(ext)
642
643
644 #----------------------------------------------------------------------
645 # Define the GLCanvas extension module
646 #----------------------------------------------------------------------
647
648 CTRB_SRC = opj(WXDIR, 'contrib/src')
649 CTRB_INC = opj(WXDIR, 'contrib/include/wx')
650
651 if BUILD_GLCANVAS:
652 msg('Preparing GLCANVAS...')
653 location = 'contrib/glcanvas'
654 swig_files = ['glcanvas.i']
655 other_sources = []
656
657 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
658 USE_SWIG, swig_force, swig_args, swig_deps)
659
660 gl_libs = []
661 if os.name == 'posix':
662 gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
663 gl_lflags = gl_config.split() + lflags
664 gl_libs = libs
665 else:
666 other_sources = [opj(location, 'msw/myglcanvas.cpp')]
667 gl_libs = libs + ['opengl32', 'glu32']
668 gl_lflags = lflags
669
670 ext = Extension('glcanvasc',
671 swig_sources + other_sources,
672
673 include_dirs = includes,
674 define_macros = defines,
675
676 library_dirs = libdirs,
677 libraries = gl_libs,
678
679 extra_compile_args = cflags,
680 extra_link_args = gl_lflags,
681 )
682
683 wxpExtensions.append(ext)
684
685
686 #----------------------------------------------------------------------
687 # Define the OGL extension module
688 #----------------------------------------------------------------------
689
690 if BUILD_OGL:
691 msg('Preparing OGL...')
692 location = 'contrib/ogl'
693 OGLLOC = opj(location, 'contrib/src/ogl')
694 OGLINC = opj(location, 'contrib/include')
695
696 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
697 'oglcanvas.i']
698
699 swig_sources = run_swig(swig_files, location, '', PKGDIR,
700 USE_SWIG, swig_force, swig_args, swig_deps)
701
702 if IN_CVS_TREE:
703 # make sure local copy of contrib files are up to date
704 contrib_copy_tree(opj(CTRB_INC, 'ogl'), opj(OGLINC, 'wx/ogl'))
705 contrib_copy_tree(opj(CTRB_SRC, 'ogl'), OGLLOC)
706
707 ext = Extension('oglc', ['%s/basic.cpp' % OGLLOC,
708 '%s/bmpshape.cpp' % OGLLOC,
709 '%s/composit.cpp' % OGLLOC,
710 '%s/divided.cpp' % OGLLOC,
711 '%s/lines.cpp' % OGLLOC,
712 '%s/misc.cpp' % OGLLOC,
713 '%s/basic2.cpp' % OGLLOC,
714 '%s/canvas.cpp' % OGLLOC,
715 '%s/constrnt.cpp' % OGLLOC,
716 '%s/drawn.cpp' % OGLLOC,
717 '%s/mfutils.cpp' % OGLLOC,
718 '%s/ogldiag.cpp' % OGLLOC,
719 ] + swig_sources,
720
721 include_dirs = [OGLINC] + includes,
722 define_macros = defines,
723
724 library_dirs = libdirs,
725 libraries = libs,
726
727 extra_compile_args = cflags,
728 extra_link_args = lflags,
729 )
730
731 wxpExtensions.append(ext)
732
733
734
735 #----------------------------------------------------------------------
736 # Define the STC extension module
737 #----------------------------------------------------------------------
738
739 if BUILD_STC:
740 msg('Preparing STC...')
741 location = 'contrib/stc'
742 STCLOC = opj(location, 'contrib/src/stc')
743 STCINC = opj(location, 'contrib/include')
744 STC_H = opj(location, 'contrib/include/wx/stc')
745
746 if IN_CVS_TREE:
747 # Check if gen_iface needs to be run for the wxSTC sources
748 if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
749 newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
750 newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
751
752 msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
753 cwd = os.getcwd()
754 os.chdir(opj(CTRB_SRC, 'stc'))
755 sys.path.insert(0, os.curdir)
756 import gen_iface
757 gen_iface.main([])
758 os.chdir(cwd)
759
760
761 # make sure local copy of contrib files are up to date
762 contrib_copy_tree(opj(CTRB_INC, 'stc'), opj(STCINC, 'wx/stc'))
763 contrib_copy_tree(opj(CTRB_SRC, 'stc'), STCLOC)
764
765
766
767 swig_files = ['stc_.i']
768 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
769 USE_SWIG, swig_force,
770 swig_args + ['-I'+STC_H, '-I'+location],
771 [opj(STC_H, 'stc.h')] + swig_deps)
772
773 # copy a contrib project specific py module to the main package dir
774 copy_file(opj(location, 'stc.py'), PKGDIR, update=1, verbose=0)
775
776 # add some include dirs to the standard set
777 stc_includes = includes[:]
778 stc_includes.append('%s/scintilla/include' % STCLOC)
779 stc_includes.append('%s/scintilla/src' % STCLOC)
780 stc_includes.append(STCINC)
781
782 # and some macro definitions
783 stc_defines = defines[:]
784 stc_defines.append( ('__WX__', None) )
785 stc_defines.append( ('SCI_LEXER', None) )
786 stc_defines.append( ('LINK_LEXERS', None) )
787
788
789 ext = Extension('stc_c',
790 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
791 '%s/scintilla/src/CallTip.cxx' % STCLOC,
792 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
793 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
794 '%s/scintilla/src/Document.cxx' % STCLOC,
795 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
796 '%s/scintilla/src/Editor.cxx' % STCLOC,
797 '%s/scintilla/src/Indicator.cxx' % STCLOC,
798 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
799 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
800 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
801 '%s/scintilla/src/PropSet.cxx' % STCLOC,
802 '%s/scintilla/src/RESearch.cxx' % STCLOC,
803 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
804 '%s/scintilla/src/Style.cxx' % STCLOC,
805 '%s/scintilla/src/StyleContext.cxx' % STCLOC,
806 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
807 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
808 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
809
810 '%s/scintilla/src/LexAda.cxx' % STCLOC,
811 '%s/scintilla/src/LexAVE.cxx' % STCLOC,
812 '%s/scintilla/src/LexBaan.cxx' % STCLOC,
813 '%s/scintilla/src/LexBullant.cxx' % STCLOC,
814 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
815 '%s/scintilla/src/LexConf.cxx' % STCLOC,
816 '%s/scintilla/src/LexCrontab.cxx' % STCLOC,
817 '%s/scintilla/src/LexEiffel.cxx' % STCLOC,
818 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
819 '%s/scintilla/src/LexLisp.cxx' % STCLOC,
820 '%s/scintilla/src/LexLua.cxx' % STCLOC,
821 '%s/scintilla/src/LexMatlab.cxx' % STCLOC,
822 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
823 '%s/scintilla/src/LexPascal.cxx' % STCLOC,
824 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
825 '%s/scintilla/src/LexPython.cxx' % STCLOC,
826 '%s/scintilla/src/LexRuby.cxx' % STCLOC,
827 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
828 '%s/scintilla/src/LexVB.cxx' % STCLOC,
829
830 '%s/PlatWX.cpp' % STCLOC,
831 '%s/ScintillaWX.cpp' % STCLOC,
832 '%s/stc.cpp' % STCLOC,
833 ] + swig_sources,
834
835 include_dirs = stc_includes,
836 define_macros = stc_defines,
837
838 library_dirs = libdirs,
839 libraries = libs,
840
841 extra_compile_args = cflags,
842 extra_link_args = lflags,
843 )
844
845 wxpExtensions.append(ext)
846
847
848
849 #----------------------------------------------------------------------
850 # Define the IEWIN extension module (experimental)
851 #----------------------------------------------------------------------
852
853 if BUILD_IEWIN:
854 msg('Preparing IEWIN...')
855 location = 'contrib/iewin'
856
857 swig_files = ['iewin.i', ]
858
859 swig_sources = run_swig(swig_files, location, '', PKGDIR,
860 USE_SWIG, swig_force, swig_args, swig_deps)
861
862
863 ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location,
864 '%s/wxactivex.cpp' % location,
865 ] + swig_sources,
866
867 include_dirs = includes,
868 define_macros = defines,
869
870 library_dirs = libdirs,
871 libraries = libs,
872
873 extra_compile_args = cflags,
874 extra_link_args = lflags,
875 )
876
877 wxpExtensions.append(ext)
878
879
880 #----------------------------------------------------------------------
881 # Define the XRC extension module
882 #----------------------------------------------------------------------
883
884 if BUILD_XRC:
885 msg('Preparing XRC...')
886 location = 'contrib/xrc'
887 XMLLOC = opj(location, 'contrib/src/xrc')
888 XMLINC = opj(location, 'contrib/include')
889
890 swig_files = ['xrc.i']
891
892 swig_sources = run_swig(swig_files, location, '', PKGDIR,
893 USE_SWIG, swig_force, swig_args, swig_deps)
894
895 xmlres_includes = includes[:]
896 xmlres_includes.append('%s/expat/xmlparse' % XMLLOC)
897 xmlres_includes.append('%s/expat/xmltok' % XMLLOC)
898 xmlres_includes.append(XMLINC)
899
900
901 # make sure local copy of contrib files are up to date
902 if IN_CVS_TREE:
903 contrib_copy_tree(opj(CTRB_INC, 'xrc'), opj(XMLINC, 'wx/xrc'))
904 contrib_copy_tree(opj(CTRB_SRC, 'xrc'), XMLLOC)
905
906 ext = Extension('xrcc', ['%s/expat/xmlparse/xmlparse.c' % XMLLOC,
907 '%s/expat/xmltok/xmlrole.c' % XMLLOC,
908 '%s/expat/xmltok/xmltok.c' % XMLLOC,
909
910 '%s/xh_bmp.cpp' % XMLLOC,
911 '%s/xh_bmpbt.cpp' % XMLLOC,
912 '%s/xh_bttn.cpp' % XMLLOC,
913 '%s/xh_cald.cpp' % XMLLOC,
914 '%s/xh_chckb.cpp' % XMLLOC,
915
916 '%s/xh_chckl.cpp' % XMLLOC,
917 '%s/xh_choic.cpp' % XMLLOC,
918 '%s/xh_combo.cpp' % XMLLOC,
919 '%s/xh_dlg.cpp' % XMLLOC,
920 '%s/xh_frame.cpp' % XMLLOC,
921
922 '%s/xh_gauge.cpp' % XMLLOC,
923 '%s/xh_gdctl.cpp' % XMLLOC,
924 '%s/xh_html.cpp' % XMLLOC,
925 '%s/xh_listb.cpp' % XMLLOC,
926 '%s/xh_listc.cpp' % XMLLOC,
927 '%s/xh_menu.cpp' % XMLLOC,
928
929 '%s/xh_notbk.cpp' % XMLLOC,
930 '%s/xh_panel.cpp' % XMLLOC,
931 '%s/xh_radbt.cpp' % XMLLOC,
932 '%s/xh_radbx.cpp' % XMLLOC,
933 '%s/xh_scrol.cpp' % XMLLOC,
934 '%s/xh_scwin.cpp' % XMLLOC,
935
936 '%s/xh_sizer.cpp' % XMLLOC,
937 '%s/xh_slidr.cpp' % XMLLOC,
938 '%s/xh_spin.cpp' % XMLLOC,
939 '%s/xh_split.cpp' % XMLLOC,
940 '%s/xh_stbmp.cpp' % XMLLOC,
941 '%s/xh_stbox.cpp' % XMLLOC,
942
943 '%s/xh_stlin.cpp' % XMLLOC,
944 '%s/xh_sttxt.cpp' % XMLLOC,
945 '%s/xh_text.cpp' % XMLLOC,
946 '%s/xh_toolb.cpp' % XMLLOC,
947 '%s/xh_tree.cpp' % XMLLOC,
948
949 '%s/xh_unkwn.cpp' % XMLLOC,
950 '%s/xml.cpp' % XMLLOC,
951 '%s/xmlres.cpp' % XMLLOC,
952 '%s/xmlrsall.cpp' % XMLLOC,
953
954 ] + swig_sources,
955
956 include_dirs = xmlres_includes,
957 define_macros = defines,
958
959 library_dirs = libdirs,
960 libraries = libs,
961
962 extra_compile_args = cflags,
963 extra_link_args = lflags,
964 )
965
966 wxpExtensions.append(ext)
967
968
969
970 #----------------------------------------------------------------------
971 # Define the GIZMOS extension module
972 #----------------------------------------------------------------------
973
974 if BUILD_GIZMOS:
975 msg('Preparing GIZMOS...')
976 location = 'contrib/gizmos'
977 GIZMOLOC = opj(location, 'contrib/src/gizmos')
978 GIZMOINC = opj(location, 'contrib/include')
979
980 swig_files = ['gizmos.i']
981
982 swig_sources = run_swig(swig_files, location, '', PKGDIR,
983 USE_SWIG, swig_force, swig_args, swig_deps)
984
985 gizmos_includes = includes[:]
986 gizmos_includes.append(GIZMOINC)
987
988
989 # make sure local copy of contrib files are up to date
990 if IN_CVS_TREE:
991 contrib_copy_tree(opj(CTRB_INC, 'gizmos'), opj(GIZMOINC, 'wx/gizmos'))
992 contrib_copy_tree(opj(CTRB_SRC, 'gizmos'), GIZMOLOC)
993
994 ext = Extension('gizmosc', [
995 '%s/dynamicsash.cpp' % GIZMOLOC,
996 '%s/editlbox.cpp' % GIZMOLOC,
997 #'%s/multicell.cpp' % GIZMOLOC,
998 '%s/splittree.cpp' % GIZMOLOC,
999 '%s/ledctrl.cpp' % GIZMOLOC,
1000 ] + swig_sources,
1001
1002 include_dirs = gizmos_includes,
1003 define_macros = defines,
1004
1005 library_dirs = libdirs,
1006 libraries = libs,
1007
1008 extra_compile_args = cflags,
1009 extra_link_args = lflags,
1010 )
1011
1012 wxpExtensions.append(ext)
1013
1014
1015
1016 #----------------------------------------------------------------------
1017 # Define the DLLWIDGET extension module
1018 #----------------------------------------------------------------------
1019
1020 if BUILD_DLLWIDGET:
1021 msg('Preparing DLLWIDGET...')
1022 location = 'contrib/dllwidget'
1023 swig_files = ['dllwidget_.i']
1024
1025 swig_sources = run_swig(swig_files, location, '', PKGDIR,
1026 USE_SWIG, swig_force, swig_args, swig_deps)
1027
1028 # copy a contrib project specific py module to the main package dir
1029 copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0)
1030
1031 ext = Extension('dllwidget_c', [
1032 '%s/dllwidget.cpp' % location,
1033 ] + swig_sources,
1034
1035 include_dirs = includes,
1036 define_macros = defines,
1037
1038 library_dirs = libdirs,
1039 libraries = libs,
1040
1041 extra_compile_args = cflags,
1042 extra_link_args = lflags,
1043 )
1044
1045 wxpExtensions.append(ext)
1046
1047
1048 #----------------------------------------------------------------------
1049 # Define the CANVAS extension module
1050 #----------------------------------------------------------------------
1051
1052 if BUILD_CANVAS:
1053 msg('Preparing CANVAS...')
1054 location = 'contrib/canvas'
1055 CANVASLOC = opj(location, 'contrib/src/canvas')
1056 CANVASINC = opj(location, 'contrib/include')
1057
1058 swig_files = ['canvas.i']
1059
1060 swig_sources = run_swig(swig_files, location, '', PKGDIR,
1061 USE_SWIG, swig_force, swig_args, swig_deps)
1062
1063 if IN_CVS_TREE:
1064 # make sure local copy of contrib files are up to date
1065 contrib_copy_tree(opj(CTRB_INC, 'canvas'), opj(CANVASINC, 'wx/canvas'))
1066 contrib_copy_tree(opj(CTRB_SRC, 'canvas'), CANVASLOC)
1067
1068 ext = Extension('canvasc', ['%s/bbox.cpp' % CANVASLOC,
1069 '%s/liner.cpp' % CANVASLOC,
1070 '%s/polygon.cpp' % CANVASLOC,
1071 '%s/canvas.cpp' % CANVASLOC,
1072 ] + swig_sources,
1073
1074 include_dirs = [CANVASINC] + includes,
1075 define_macros = defines,
1076
1077 library_dirs = libdirs,
1078 libraries = libs,
1079
1080 extra_compile_args = cflags,
1081 extra_link_args = lflags,
1082 )
1083
1084 wxpExtensions.append(ext)
1085
1086
1087 #----------------------------------------------------------------------
1088 # Define the ART2D extension module
1089 #----------------------------------------------------------------------
1090
1091 if BUILD_ART2D:
1092 msg('Preparing ART2D...')
1093 location = 'contrib/art2d'
1094 ART2DLOC = opj(location, 'modules/canvas/src')
1095 ART2DINC = opj(location, 'modules/canvas/include')
1096 EXPATLOC = opj(location, 'modules/expat')
1097 EXPATINC = opj(location, 'modules/expat/include')
1098
1099 swig_files = ['art2d.i',
1100 'art2d_misc.i',
1101 'art2d_base.i',
1102 'art2d_canvas.i',
1103 ]
1104
1105 swig_sources = run_swig(swig_files, location, '', PKGDIR,
1106 USE_SWIG, swig_force, swig_args, swig_deps)
1107
1108 if IN_CVS_TREE:
1109 # Don't copy data in this case as the code snapshots are
1110 # taken manually
1111 pass
1112
1113 ext = Extension('art2dc', [ opj(ART2DLOC, 'afmatrix.cpp'),
1114 opj(ART2DLOC, 'bbox.cpp'),
1115 opj(ART2DLOC, 'cancom.cpp'),
1116 opj(ART2DLOC, 'candoc.cpp'),
1117 opj(ART2DLOC, 'canglob.cpp'),
1118 opj(ART2DLOC, 'canobj3d.cpp'),
1119 opj(ART2DLOC, 'canobj.cpp'),
1120 opj(ART2DLOC, 'canprim.cpp'),
1121 opj(ART2DLOC, 'canprop.cpp'),
1122 opj(ART2DLOC, 'canvas.cpp'),
1123 opj(ART2DLOC, 'docviewref.cpp'),
1124 opj(ART2DLOC, 'drawer.cpp'),
1125 opj(ART2DLOC, 'eval.cpp'),
1126 opj(ART2DLOC, 'graph.cpp'),
1127 opj(ART2DLOC, 'layerinf.cpp'),
1128 opj(ART2DLOC, 'liner.cpp'),
1129 opj(ART2DLOC, 'meta.cpp'),
1130 opj(ART2DLOC, 'objlist.cpp'),
1131 opj(ART2DLOC, 'polygon.cpp'),
1132 opj(ART2DLOC, 'recur.cpp'),
1133 opj(ART2DLOC, 'rendimg.cpp'),
1134 opj(ART2DLOC, 'tools.cpp'),
1135 opj(ART2DLOC, 'vpath.cpp'),
1136 opj(ART2DLOC, 'xmlpars.cpp'),
1137
1138 opj(EXPATLOC, 'xmlparse/xmlparse.c'),
1139 opj(EXPATLOC, 'xmltok/xmlrole.c'),
1140 opj(EXPATLOC, 'xmltok/xmltok.c'),
1141
1142 ] + swig_sources,
1143
1144 include_dirs = [ ART2DINC,
1145 EXPATINC,
1146 opj(EXPATLOC, 'xmltok'),
1147 opj(EXPATLOC, 'xmlparse'),
1148 ] + includes,
1149 define_macros = defines,
1150
1151 library_dirs = libdirs,
1152 libraries = libs,
1153
1154 extra_compile_args = cflags,
1155 extra_link_args = lflags,
1156 )
1157
1158 wxpExtensions.append(ext)
1159
1160
1161 #----------------------------------------------------------------------
1162 # Tools and scripts
1163 #----------------------------------------------------------------------
1164
1165 if NO_SCRIPTS:
1166 SCRIPTS = None
1167 else:
1168 SCRIPTS = [opj('scripts/helpviewer'),
1169 opj('scripts/img2png'),
1170 opj('scripts/img2xpm'),
1171 opj('scripts/img2py'),
1172 opj('scripts/xrced'),
1173 opj('scripts/pyshell'),
1174 opj('scripts/pycrust'),
1175 opj('scripts/pycwrap'),
1176 ]
1177
1178
1179 DATA_FILES.append( ('wxPython/tools/XRCed', glob.glob('wxPython/tools/XRCed/*.txt') +
1180 [ 'wxPython/tools/XRCed/xrced.xrc']))
1181
1182 DATA_FILES.append( ('wxPython/lib/PyCrust', glob.glob('wxPython/lib/PyCrust/*.txt') +
1183 glob.glob('wxPython/lib/PyCrust/*.ico')))
1184
1185
1186 #----------------------------------------------------------------------
1187 # Do the Setup/Build/Install/Whatever
1188 #----------------------------------------------------------------------
1189
1190 if __name__ == "__main__":
1191 if not PREP_ONLY:
1192 setup(name = PKGDIR,
1193 version = VERSION,
1194 description = DESCRIPTION,
1195 long_description = LONG_DESCRIPTION,
1196 author = AUTHOR,
1197 author_email = AUTHOR_EMAIL,
1198 url = URL,
1199 license = LICENSE,
1200
1201 packages = [PKGDIR,
1202 PKGDIR+'.lib',
1203 PKGDIR+'.lib.colourchooser',
1204 PKGDIR+'.lib.editor',
1205 PKGDIR+'.lib.mixins',
1206 PKGDIR+'.lib.PyCrust',
1207 PKGDIR+'.lib.PyCrust.wxd',
1208 PKGDIR+'.tools',
1209 PKGDIR+'.tools.XRCed',
1210 ],
1211
1212 ext_package = PKGDIR,
1213 ext_modules = wxpExtensions,
1214
1215 options = { 'build' : { 'build_base' : BUILD_BASE }},
1216
1217 scripts = SCRIPTS,
1218
1219 cmdclass = { 'install_data': smart_install_data},
1220 data_files = DATA_FILES,
1221
1222 )
1223
1224
1225 #----------------------------------------------------------------------
1226 #----------------------------------------------------------------------