]> git.saurik.com Git - wxWidgets.git/blame - wxPython/setup.py
fixed the width of the (week day as number) field, should be 1, not 2
[wxWidgets.git] / wxPython / setup.py
CommitLineData
c368d904
RD
1#!/usr/bin/env python
2#----------------------------------------------------------------------
3
8916d007 4import sys, os, string, glob
c368d904
RD
5from distutils.core import setup, Extension
6from distutils.file_util import copy_file
7from distutils.dir_util import mkpath
8from distutils.dep_util import newer
9
10from my_distutils import run_swig, contrib_copy_tree
11
12#----------------------------------------------------------------------
13# flags and values that affect this script
14#----------------------------------------------------------------------
15
efe12e95 16VERSION = "2.3.3pre6"
c368d904
RD
17DESCRIPTION = "Cross platform GUI toolkit for Python"
18AUTHOR = "Robin Dunn"
b166c703 19AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>"
c368d904 20URL = "http://wxPython.org/"
e2e02194 21LICENSE = "wxWindows (LGPL derivative)"
c368d904
RD
22LONG_DESCRIPTION = """\
23wxPython is a GUI toolkit for Python that is a wrapper around the
24wxWindows C++ GUI library. wxPython provides a large variety of
1b62f00d 25window types and controls, all implemented with a native look and
c368d904
RD
26feel (and native runtime speed) on the platforms it is supported
27on.
28"""
29
30
f221f8eb 31BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module
c368d904
RD
32BUILD_OGL = 1 # If true, build the contrib/ogl extension module
33BUILD_STC = 1 # If true, build the contrib/stc extension module
d56cebe7 34BUILD_XRC = 1 # XML based resource system
ebf4302c 35BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library
37bd51c0
RD
36BUILD_DLLWIDGET = 1# Build a module that enables unknown wx widgets
37 # to be loaded from a DLL and to be used from Python.
d56cebe7 38
c731eb47
RD
39 # Internet Explorer wrapper (experimental)
40BUILD_IEWIN = (os.name == 'nt')
78e8819c 41
c368d904 42CORE_ONLY = 0 # if true, don't build any of the above
4a61305d 43
f221f8eb 44GL_ONLY = 0 # Only used when making the -gl RPM. See the "b" script
1b62f00d 45 # for the ugly details
c368d904
RD
46
47USE_SWIG = 0 # Should we actually execute SWIG, or just use the
48 # files already in the distribution?
49
a541c325
RD
50UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG and
51 # will ensure that the right headers are found and the
52 # right libs are linked.
c8bc7bb8 53
c368d904
RD
54IN_CVS_TREE = 0 # Set to true if building in a full wxWindows CVS
55 # tree, otherwise will assume all needed files are
56 # available in the wxPython source distribution
57
5c8e1089
RD
58UNDEF_NDEBUG = 1 # Python 2.2 on Unix/Linux by default defines NDEBUG,
59 # and distutils will pick this up and use it on the
60 # compile command-line for the extensions. This could
61 # conflict with how wxWindows was built. If NDEBUG is
62 # set then wxWindows' __WXDEBUG__ setting will be turned
63 # off. If wxWindows was actually built with it turned
64 # on then you end up with mismatched class structures,
65 # and wxPython will crash.
66
2eb31f8b
RD
67NO_SCRIPTS = 0 # Don't install the tool scripts
68
69
afa3e1ed
RL
70WX_CONFIG = "wx-config" # Usually you shouldn't need to touch this,
71 # but you can set it to pass an alternate
72 # version of wx-config or alternate flags,
73 # eg. as required by the .deb in-tree build.
c368d904 74
a541c325
RD
75BUILD_BASE = "build"
76
c368d904
RD
77# Some MSW build settings
78
d440a0e7 79FINAL = 0 # Mirrors use of same flag in wx makefiles,
c368d904
RD
80 # (0 or 1 only) should probably find a way to
81 # autodetect this...
82
d440a0e7 83HYBRID = 1 # If set and not debug or FINAL, then build a
c368d904
RD
84 # hybrid extension that can be used by the
85 # non-debug version of python, but contains
86 # debugging symbols for wxWindows and wxPython.
87 # wxWindows must have been built with /MD, not /MDd
88 # (using FINAL=hybrid will do it.)
89
a541c325 90WXDLLVER = '233' # Version part of wxWindows DLL name
c368d904
RD
91
92
cfe766c3
RD
93#----------------------------------------------------------------------
94
95def msg(text):
96 if __name__ == "__main__":
97 print text
98
a541c325 99
55c020cf
RD
100def opj(*args):
101 path = apply(os.path.join, args)
102 return os.path.normpath(path)
cfe766c3 103
a541c325 104
a4fbdd76
RD
105def libFlag():
106 if FINAL:
c8bc7bb8 107 rv = ''
a4fbdd76 108 elif HYBRID:
c8bc7bb8 109 rv = 'h'
a4fbdd76 110 else:
c8bc7bb8 111 rv = 'd'
a541c325 112 if UNICODE:
c8bc7bb8
RD
113 rv = 'u' + rv
114 return rv
a4fbdd76
RD
115
116
c368d904
RD
117#----------------------------------------------------------------------
118# Some other globals
119#----------------------------------------------------------------------
120
121PKGDIR = 'wxPython'
122wxpExtensions = []
123
124force = '--force' in sys.argv or '-f' in sys.argv
125debug = '--debug' in sys.argv or '-g' in sys.argv
126
22d08289
RD
127bcpp_compiling = '-c' in sys.argv and 'my_bcpp' in sys.argv # Bad heuristic
128
129if bcpp_compiling:
cfe766c3 130 msg("Compiling wxPython by Borland C/C++ Compiler")
22d08289
RD
131 HYBRID=0
132 WXBCPPLIBVER = string.replace(WXDLLVER,"_","")
133 # Version part of BCPP build LIBRARY name
134 WXDLLVER="" # no dll ver path avaible
135
c368d904
RD
136
137#----------------------------------------------------------------------
138# Check for build flags on the command line
139#----------------------------------------------------------------------
140
5c8e1089 141# Boolean (int) flags
b166c703 142for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC',
c731eb47 143 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN',
2eb31f8b
RD
144 'CORE_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'UNICODE',
145 'UNDEF_NDEBUG', 'NO_SCRIPTS',
b166c703 146 'FINAL', 'HYBRID', ]:
c368d904
RD
147 for x in range(len(sys.argv)):
148 if string.find(sys.argv[x], flag) == 0:
149 pos = string.find(sys.argv[x], '=') + 1
150 if pos > 0:
151 vars()[flag] = eval(sys.argv[x][pos:])
152 sys.argv[x] = ''
153
5c8e1089
RD
154# String options
155for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE']:
afa3e1ed
RL
156 for x in range(len(sys.argv)):
157 if string.find(sys.argv[x], option) == 0:
158 pos = string.find(sys.argv[x], '=') + 1
159 if pos > 0:
160 vars()[option] = sys.argv[x][pos:]
161 sys.argv[x] = ''
162
c368d904
RD
163sys.argv = filter(None, sys.argv)
164
165
c8bc7bb8
RD
166
167#----------------------------------------------------------------------
168# sanity checks
169
c368d904 170if CORE_ONLY:
f221f8eb 171 BUILD_GLCANVAS = 0
c368d904
RD
172 BUILD_OGL = 0
173 BUILD_STC = 0
b166c703 174 BUILD_XRC = 0
ff5f1aba
RD
175 BUILD_GIZMOS = 0
176 BUILD_DLLWIDGET = 0
c731eb47 177 BUILD_IEWIN = 0
ff5f1aba 178
c368d904 179
a541c325 180if UNICODE and os.name != 'nt':
c8bc7bb8
RD
181 print "UNICODE is currently only supported on Win32"
182 sys.exit()
183
a541c325
RD
184
185if UNICODE:
186 BUILD_BASE = BUILD_BASE + '.unicode'
fc51b8c3 187 VERSION = VERSION + 'u'
a541c325
RD
188
189
c368d904
RD
190#----------------------------------------------------------------------
191# Setup some platform specific stuff
192#----------------------------------------------------------------------
193
194if os.name == 'nt':
195 # Set compile flags and such for MSVC. These values are derived
a541c325
RD
196 # from the wxWindows makefiles for MSVC, other compilers settings
197 # will probably vary...
198 if os.environ.has_key('WXWIN'):
199 WXDIR = os.environ['WXWIN']
200 else:
201 msg("WARNING: WXWIN not set in environment.")
202 WXDIR = '..' # assumes in CVS tree
c368d904
RD
203 WXPLAT = '__WXMSW__'
204 GENDIR = 'msw'
205
c368d904
RD
206 if debug:
207 FINAL = 0
208 HYBRID = 0
209
210 if HYBRID:
211 FINAL = 0
212
c368d904 213 includes = ['src',
a4fbdd76 214 opj(WXDIR, 'lib', 'mswdll' + libFlag()),
55c020cf 215 opj(WXDIR, 'include'),
c368d904
RD
216 ]
217
218 defines = [ ('WIN32', None), # Some of these are no longer
219 ('__WIN32__', None), # necessary. Anybody know which?
220 ('_WINDOWS', None),
221 ('__WINDOWS__', None),
222 ('WINVER', '0x0400'),
223 ('__WIN95__', None),
224 ('STRICT', None),
225
226 (WXPLAT, None),
227 ('WXUSINGDLL', '1'),
228
229 ('SWIG_GLOBAL', None),
230 ('HAVE_CONFIG_H', None),
231 ('WXP_USE_THREAD', '1'),
232 ]
233
22d08289
RD
234 if bcpp_compiling: # overwrite it
235 defines = [
236 ('_WINDOWS', None),
237 ('WINVER', '0x0400'),
238 ('STRICT', None),
239
240 ('WXUSINGDLL', '1'),
241
242 ('SWIG_GLOBAL', None),
243 ('HAVE_CONFIG_H', None),
244 ('WXP_USE_THREAD', '1'),
245
246 ('WXUSE_DEFINE','1'),
247 ('_RTLDLL',None),
248 ]
249
250
c368d904
RD
251 if not FINAL or HYBRID:
252 defines.append( ('__WXDEBUG__', None) )
253
d440a0e7 254 libdirs = [ opj(WXDIR, 'lib') ]
a4fbdd76 255 wxdll = 'wxmsw' + WXDLLVER + libFlag()
d440a0e7 256 libs = [ wxdll ]
a4fbdd76 257
22d08289 258 if bcpp_compiling:
d440a0e7 259 libs = [ 'wx'+WXBCPPLIBVER ]
22d08289
RD
260
261 libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
c368d904
RD
262 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
263 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
264 'advapi32', 'wsock32']
265
22d08289 266
d440a0e7 267 cflags = [ '/Gy',
ad07d019
RD
268 # '/GX-' # workaround for internal compiler error in MSVC on some machines
269 ]
c368d904
RD
270 lflags = None
271
22d08289 272
d440a0e7 273 if bcpp_compiling: # BCC flags
dbd3685c 274 cflags = ['-5', '-VF', ### To support MSVC spurious semicolons in the class scope
22d08289 275 ### else, all semicolons at the end of all DECLARE_...CALLBACK... macros must be eliminated
55c020cf
RD
276 '-Hc', '-H=' + opj(WXDIR, '\src\msw\wx32.csm'),
277 '@' + opj(WXDIR, '\src\msw\wxwin32.cfg')
22d08289 278 ]
d440a0e7
RD
279 if not FINAL:
280 cflags = cflags + ['/Od', '/v', '/y']
281 lflags = lflags + ['/v', ]
282
283 else: # MSVC flags
284 if FINAL:
285 pass #cflags = cflags + ['/O1']
286 elif HYBRID :
287 pass #cflags = cflags + ['/Ox']
288 else:
289 pass # cflags = cflags + ['/Od', '/Z7']
290 # lflags = ['/DEBUG', ]
22d08289
RD
291
292
22d08289 293
c368d904 294
dbd3685c 295elif os.name == 'posix' and sys.platform[:6] == "darwin":
e6056257
RD
296 # Flags and such for a Darwin (Max OS X) build of Python
297
298 WXDIR = '..' # assumes IN_CVS_TREE
299 WXPLAT = '__WXMAC__'
300 GENDIR = 'mac'
301
302 includes = ['src']
303 defines = [('SWIG_GLOBAL', None),
304 ('HAVE_CONFIG_H', None),
305 ('WXP_USE_THREAD', '1'),
306 ]
307 libdirs = []
308 libs = []
309
310 cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1]
311 cflags = string.split(cflags)
5c8e1089
RD
312 if UNDEF_NDEBUG:
313 cflags.append('-UNDEBUG')
ba201fa4
RD
314 if debug:
315 cflags.append('-g')
316 cflags.append('-O0')
e6056257
RD
317
318 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
319 lflags = string.split(lflags)
320
2eb31f8b 321 NO_SCRIPTS = 1
e6056257
RD
322
323
c368d904
RD
324elif os.name == 'posix':
325 # Set flags for Unix type platforms
326
327 WXDIR = '..' # assumes IN_CVS_TREE
328 WXPLAT = '__WXGTK__' # and assumes GTK...
329 GENDIR = 'gtk' # Need to allow for Motif eventually too
330
331 includes = ['src']
332 defines = [('SWIG_GLOBAL', None),
333 ('HAVE_CONFIG_H', None),
334 ('WXP_USE_THREAD', '1'),
335 ]
336 libdirs = []
337 libs = []
338
e8bf92fd 339 cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1] + ' ' + \
c368d904
RD
340 os.popen('gtk-config --cflags', 'r').read()[:-1]
341 cflags = string.split(cflags)
5c8e1089
RD
342 if UNDEF_NDEBUG:
343 cflags.append('-UNDEBUG')
ba201fa4
RD
344 if debug:
345 cflags.append('-g')
346 cflags.append('-O0')
c368d904 347
afa3e1ed 348 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
c368d904
RD
349 lflags = string.split(lflags)
350
351
352else:
353 raise 'Sorry Charlie...'
354
355
356#----------------------------------------------------------------------
357# Check if the version file needs updated
358#----------------------------------------------------------------------
359
b8510c2f
RD
360#if IN_CVS_TREE and newer('setup.py', 'src/__version__.py'):
361open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION)
c368d904 362
1b62f00d
RD
363
364
c368d904 365#----------------------------------------------------------------------
1b62f00d 366# SWIG defaults
c368d904
RD
367#----------------------------------------------------------------------
368
c368d904 369swig_force = force
00b6c4e3
RD
370swig_args = ['-c++', '-shadow', '-python', '-keyword',
371 '-dnone',
372 #'-dascii',
373 #'-docstring', '-Sbefore',
e6056257
RD
374 '-I./src', '-D'+WXPLAT,
375 ]
a541c325 376if UNICODE:
c8bc7bb8
RD
377 swig_args.append('-DwxUSE_UNICODE')
378
185d7c3e 379swig_deps = ['src/my_typemaps.i']
c368d904 380
c368d904 381
1b62f00d
RD
382#----------------------------------------------------------------------
383# Define the CORE extension module
384#----------------------------------------------------------------------
385
386if not GL_ONLY:
cfe766c3 387 msg('Preparing CORE...')
1b62f00d
RD
388 swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
389 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
390 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
391 'printfw.i', 'sizers.i', 'clip_dnd.i',
68bc8549 392 'filesys.i', 'streams.i', 'utils.i', 'fonts.i'
1b62f00d 393 ]
c368d904 394
1b62f00d
RD
395 swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
396 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904 397
1b62f00d
RD
398 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
399 copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
b96c7a38 400 copy_file('src/wxc.pyd.manifest', PKGDIR, update=1, verbose=0)
c368d904 401
e2e02194 402 if IN_CVS_TREE: # update the license files
1b62f00d
RD
403 mkpath('licence')
404 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
55c020cf 405 copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0)
c368d904 406
1b62f00d
RD
407
408 if os.name == 'nt':
409 rc_file = ['src/wxc.rc']
410 else:
411 rc_file = []
412
413
414 ext = Extension('wxc', ['src/helpers.cpp',
415 'src/libpy.c',
416 ] + rc_file + swig_sources,
417
418 include_dirs = includes,
419 define_macros = defines,
420
421 library_dirs = libdirs,
422 libraries = libs,
423
424 extra_compile_args = cflags,
425 extra_link_args = lflags,
426 )
427 wxpExtensions.append(ext)
428
429
430 # Extension for the grid module
431 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
432 USE_SWIG, swig_force, swig_args, swig_deps)
433 ext = Extension('gridc', swig_sources,
434 include_dirs = includes,
435 define_macros = defines,
436 library_dirs = libdirs,
437 libraries = libs,
438 extra_compile_args = cflags,
439 extra_link_args = lflags,
440 )
441 wxpExtensions.append(ext)
442
443
444 # Extension for the html modules
445 swig_sources = run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR, PKGDIR,
446 USE_SWIG, swig_force, swig_args, swig_deps)
447 ext = Extension('htmlc', swig_sources,
448 include_dirs = includes,
449 define_macros = defines,
450 library_dirs = libdirs,
1b62f00d
RD
451 libraries = libs,
452 extra_compile_args = cflags,
453 extra_link_args = lflags,
454 )
455 wxpExtensions.append(ext)
456
457
458 # Extension for the calendar module
459 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
460 USE_SWIG, swig_force, swig_args, swig_deps)
461 ext = Extension('calendarc', swig_sources,
462 include_dirs = includes,
463 define_macros = defines,
464 library_dirs = libdirs,
465 libraries = libs,
466 extra_compile_args = cflags,
467 extra_link_args = lflags,
468 )
469 wxpExtensions.append(ext)
c368d904 470
c368d904 471
4f3449b4
RD
472 # Extension for the help module
473 swig_sources = run_swig(['help.i'], 'src', GENDIR, PKGDIR,
474 USE_SWIG, swig_force, swig_args, swig_deps)
475 ext = Extension('helpc', swig_sources,
476 include_dirs = includes,
477 define_macros = defines,
478 library_dirs = libdirs,
479 libraries = libs,
480 extra_compile_args = cflags,
481 extra_link_args = lflags,
482 )
483 wxpExtensions.append(ext)
484
485
af83019e
RD
486 # Extension for the wizard module
487 swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR,
488 USE_SWIG, swig_force, swig_args, swig_deps)
489 ext = Extension('wizardc', swig_sources,
490 include_dirs = includes,
491 define_macros = defines,
492 library_dirs = libdirs,
493 libraries = libs,
494 extra_compile_args = cflags,
495 extra_link_args = lflags,
496 )
497 wxpExtensions.append(ext)
498
499
c368d904
RD
500#----------------------------------------------------------------------
501# Define the GLCanvas extension module
502#----------------------------------------------------------------------
503
55c020cf
RD
504CTRB_SRC = opj(WXDIR, 'contrib/src')
505CTRB_INC = opj(WXDIR, 'contrib/include/wx')
506
1b62f00d 507if BUILD_GLCANVAS or GL_ONLY:
cfe766c3 508 msg('Preparing GLCANVAS...')
c368d904
RD
509 location = 'contrib/glcanvas'
510 swig_files = ['glcanvas.i']
19cf4f80 511 other_sources = []
c368d904
RD
512
513 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
10ef30eb 514 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904
RD
515
516 gl_libs = []
517 if os.name == 'posix':
f32afe1c
RD
518 gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
519 gl_lflags = string.split(gl_config) + lflags
520 gl_libs = libs
19cf4f80 521 else:
55c020cf 522 other_sources = [opj(location, 'msw/myglcanvas.cpp')]
f32afe1c
RD
523 gl_libs = libs + ['opengl32', 'glu32']
524 gl_lflags = lflags
c368d904 525
1e7ecb7b 526 ext = Extension('glcanvasc',
19cf4f80 527 swig_sources + other_sources,
1e7ecb7b
RD
528
529 include_dirs = includes,
530 define_macros = defines,
531
532 library_dirs = libdirs,
f32afe1c 533 libraries = gl_libs,
1e7ecb7b
RD
534
535 extra_compile_args = cflags,
f32afe1c 536 extra_link_args = gl_lflags,
1e7ecb7b
RD
537 )
538
539 wxpExtensions.append(ext)
c368d904
RD
540
541
542#----------------------------------------------------------------------
543# Define the OGL extension module
544#----------------------------------------------------------------------
545
1b62f00d 546if not GL_ONLY and BUILD_OGL:
cfe766c3 547 msg('Preparing OGL...')
c368d904 548 location = 'contrib/ogl'
55c020cf
RD
549 OGLLOC = opj(location, 'contrib/src/ogl')
550 OGLINC = opj(location, 'contrib/include')
c368d904
RD
551
552 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
553 'oglcanvas.i']
554
555 swig_sources = run_swig(swig_files, location, '', PKGDIR,
10ef30eb 556 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904 557
c368d904 558 if IN_CVS_TREE:
55c020cf
RD
559 # make sure local copy of contrib files are up to date
560 contrib_copy_tree(opj(CTRB_INC, 'ogl'), opj(OGLINC, 'wx/ogl'))
561 contrib_copy_tree(opj(CTRB_SRC, 'ogl'), OGLLOC)
c368d904 562
1e7ecb7b
RD
563 ext = Extension('oglc', ['%s/basic.cpp' % OGLLOC,
564 '%s/bmpshape.cpp' % OGLLOC,
565 '%s/composit.cpp' % OGLLOC,
566 '%s/divided.cpp' % OGLLOC,
567 '%s/lines.cpp' % OGLLOC,
568 '%s/misc.cpp' % OGLLOC,
569 '%s/basic2.cpp' % OGLLOC,
570 '%s/canvas.cpp' % OGLLOC,
571 '%s/constrnt.cpp' % OGLLOC,
572 '%s/drawn.cpp' % OGLLOC,
573 '%s/mfutils.cpp' % OGLLOC,
574 '%s/ogldiag.cpp' % OGLLOC,
575 ] + swig_sources,
576
577 include_dirs = [OGLINC] + includes,
578 define_macros = defines,
579
580 library_dirs = libdirs,
581 libraries = libs,
582
583 extra_compile_args = cflags,
584 extra_link_args = lflags,
585 )
586
587 wxpExtensions.append(ext)
588
589
c368d904
RD
590
591#----------------------------------------------------------------------
592# Define the STC extension module
593#----------------------------------------------------------------------
594
1b62f00d 595if not GL_ONLY and BUILD_STC:
cfe766c3 596 msg('Preparing STC...')
c368d904 597 location = 'contrib/stc'
55c020cf
RD
598 STCLOC = opj(location, 'contrib/src/stc')
599 STCINC = opj(location, 'contrib/include')
600 STC_H = opj(location, 'contrib/include/wx/stc')
c368d904 601
c368d904 602 if IN_CVS_TREE:
55c020cf
RD
603 # Check if gen_iface needs to be run for the wxSTC sources
604 if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
605 newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
606 newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
607
608 msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
609 cwd = os.getcwd()
610 os.chdir(opj(CTRB_SRC, 'stc'))
611 import gen_iface
612 gen_iface.main([])
613 os.chdir(cwd)
614
615
616 # make sure local copy of contrib files are up to date
617 contrib_copy_tree(opj(CTRB_INC, 'stc'), opj(STCINC, 'wx/stc'))
618 contrib_copy_tree(opj(CTRB_SRC, 'stc'), STCLOC)
619
c368d904
RD
620
621
622 swig_files = ['stc_.i']
74933d75 623 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
c368d904
RD
624 USE_SWIG, swig_force,
625 swig_args + ['-I'+STC_H, '-I'+location],
10ef30eb 626 [opj(STC_H, 'stc.h')] + swig_deps)
c368d904 627
4a61305d 628 # copy a contrib project specific py module to the main package dir
55c020cf 629 copy_file(opj(location, 'stc.py'), PKGDIR, update=1, verbose=0)
c368d904
RD
630
631 # add some include dirs to the standard set
1e7ecb7b
RD
632 stc_includes = includes[:]
633 stc_includes.append('%s/scintilla/include' % STCLOC)
634 stc_includes.append('%s/scintilla/src' % STCLOC)
635 stc_includes.append(STCINC)
c368d904
RD
636
637 # and some macro definitions
1e7ecb7b
RD
638 stc_defines = defines[:]
639 stc_defines.append( ('__WX__', None) )
640 stc_defines.append( ('SCI_LEXER', None) )
1a2fb4cd 641 stc_defines.append( ('LINK_LEXERS', None) )
c368d904
RD
642
643
1e7ecb7b
RD
644 ext = Extension('stc_c',
645 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
c368d904
RD
646 '%s/scintilla/src/CallTip.cxx' % STCLOC,
647 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
648 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
649 '%s/scintilla/src/Document.cxx' % STCLOC,
55c020cf 650 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
c368d904
RD
651 '%s/scintilla/src/Editor.cxx' % STCLOC,
652 '%s/scintilla/src/Indicator.cxx' % STCLOC,
653 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
654 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
655 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
656 '%s/scintilla/src/PropSet.cxx' % STCLOC,
55c020cf 657 '%s/scintilla/src/RESearch.cxx' % STCLOC,
c368d904
RD
658 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
659 '%s/scintilla/src/Style.cxx' % STCLOC,
fe0aca37 660 '%s/scintilla/src/StyleContext.cxx' % STCLOC,
55c020cf 661 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
c368d904 662 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
55c020cf
RD
663 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
664
665 '%s/scintilla/src/LexAda.cxx' % STCLOC,
666 '%s/scintilla/src/LexAVE.cxx' % STCLOC,
1a2fb4cd
RD
667 '%s/scintilla/src/LexBaan.cxx' % STCLOC,
668 '%s/scintilla/src/LexBullant.cxx' % STCLOC,
c368d904 669 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
fe0aca37
RD
670 '%s/scintilla/src/LexConf.cxx' % STCLOC,
671 '%s/scintilla/src/LexCrontab.cxx' % STCLOC,
55c020cf 672 '%s/scintilla/src/LexEiffel.cxx' % STCLOC,
c368d904 673 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
55c020cf 674 '%s/scintilla/src/LexLisp.cxx' % STCLOC,
c368d904 675 '%s/scintilla/src/LexLua.cxx' % STCLOC,
1a2fb4cd 676 '%s/scintilla/src/LexMatlab.cxx' % STCLOC,
c368d904 677 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
55c020cf 678 '%s/scintilla/src/LexPascal.cxx' % STCLOC,
c368d904
RD
679 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
680 '%s/scintilla/src/LexPython.cxx' % STCLOC,
55c020cf 681 '%s/scintilla/src/LexRuby.cxx' % STCLOC,
c368d904
RD
682 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
683 '%s/scintilla/src/LexVB.cxx' % STCLOC,
c368d904
RD
684
685 '%s/PlatWX.cpp' % STCLOC,
686 '%s/ScintillaWX.cpp' % STCLOC,
687 '%s/stc.cpp' % STCLOC,
1e7ecb7b
RD
688 ] + swig_sources,
689
690 include_dirs = stc_includes,
691 define_macros = stc_defines,
692
693 library_dirs = libdirs,
694 libraries = libs,
c368d904 695
1e7ecb7b
RD
696 extra_compile_args = cflags,
697 extra_link_args = lflags,
698 )
699
700 wxpExtensions.append(ext)
c368d904
RD
701
702
703
926bb76c
RD
704#----------------------------------------------------------------------
705# Define the IEWIN extension module (experimental)
706#----------------------------------------------------------------------
707
708if not GL_ONLY and BUILD_IEWIN:
cfe766c3 709 msg('Preparing IEWIN...')
926bb76c
RD
710 location = 'contrib/iewin'
711
712 swig_files = ['iewin.i', ]
713
714 swig_sources = run_swig(swig_files, location, '', PKGDIR,
10ef30eb 715 USE_SWIG, swig_force, swig_args, swig_deps)
926bb76c
RD
716
717
718 ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location,
c731eb47 719 '%s/wxactivex.cpp' % location,
926bb76c
RD
720 ] + swig_sources,
721
722 include_dirs = includes,
723 define_macros = defines,
724
725 library_dirs = libdirs,
726 libraries = libs,
727
728 extra_compile_args = cflags,
729 extra_link_args = lflags,
730 )
731
732 wxpExtensions.append(ext)
733
734
d56cebe7
RD
735#----------------------------------------------------------------------
736# Define the XRC extension module
737#----------------------------------------------------------------------
738
739if not GL_ONLY and BUILD_XRC:
cfe766c3 740 msg('Preparing XRC...')
d56cebe7 741 location = 'contrib/xrc'
55c020cf
RD
742 XMLLOC = opj(location, 'contrib/src/xrc')
743 XMLINC = opj(location, 'contrib/include')
d56cebe7
RD
744
745 swig_files = ['xrc.i']
746
747 swig_sources = run_swig(swig_files, location, '', PKGDIR,
10ef30eb 748 USE_SWIG, swig_force, swig_args, swig_deps)
d56cebe7
RD
749
750 xmlres_includes = includes[:]
751 xmlres_includes.append('%s/expat/xmlparse' % XMLLOC)
752 xmlres_includes.append('%s/expat/xmltok' % XMLLOC)
753 xmlres_includes.append(XMLINC)
754
755
756 # make sure local copy of contrib files are up to date
757 if IN_CVS_TREE:
55c020cf
RD
758 contrib_copy_tree(opj(CTRB_INC, 'xrc'), opj(XMLINC, 'wx/xrc'))
759 contrib_copy_tree(opj(CTRB_SRC, 'xrc'), XMLLOC)
d56cebe7
RD
760
761 ext = Extension('xrcc', ['%s/expat/xmlparse/xmlparse.c' % XMLLOC,
762 '%s/expat/xmltok/xmlrole.c' % XMLLOC,
763 '%s/expat/xmltok/xmltok.c' % XMLLOC,
764
765 '%s/xh_bmp.cpp' % XMLLOC,
766 '%s/xh_bmpbt.cpp' % XMLLOC,
767 '%s/xh_bttn.cpp' % XMLLOC,
768 '%s/xh_cald.cpp' % XMLLOC,
769 '%s/xh_chckb.cpp' % XMLLOC,
770
771 '%s/xh_chckl.cpp' % XMLLOC,
772 '%s/xh_choic.cpp' % XMLLOC,
773 '%s/xh_combo.cpp' % XMLLOC,
774 '%s/xh_dlg.cpp' % XMLLOC,
775 '%s/xh_frame.cpp' % XMLLOC,
776
777 '%s/xh_gauge.cpp' % XMLLOC,
6c5ae2d2 778 '%s/xh_gdctl.cpp' % XMLLOC,
d56cebe7
RD
779 '%s/xh_html.cpp' % XMLLOC,
780 '%s/xh_listb.cpp' % XMLLOC,
781 '%s/xh_listc.cpp' % XMLLOC,
782 '%s/xh_menu.cpp' % XMLLOC,
783
784 '%s/xh_notbk.cpp' % XMLLOC,
785 '%s/xh_panel.cpp' % XMLLOC,
786 '%s/xh_radbt.cpp' % XMLLOC,
787 '%s/xh_radbx.cpp' % XMLLOC,
788 '%s/xh_scrol.cpp' % XMLLOC,
789
790 '%s/xh_sizer.cpp' % XMLLOC,
791 '%s/xh_slidr.cpp' % XMLLOC,
792 '%s/xh_spin.cpp' % XMLLOC,
793 '%s/xh_stbmp.cpp' % XMLLOC,
794 '%s/xh_stbox.cpp' % XMLLOC,
795
796 '%s/xh_stlin.cpp' % XMLLOC,
797 '%s/xh_sttxt.cpp' % XMLLOC,
798 '%s/xh_text.cpp' % XMLLOC,
799 '%s/xh_toolb.cpp' % XMLLOC,
800 '%s/xh_tree.cpp' % XMLLOC,
801
802 '%s/xh_unkwn.cpp' % XMLLOC,
803 '%s/xml.cpp' % XMLLOC,
d56cebe7
RD
804 '%s/xmlres.cpp' % XMLLOC,
805 '%s/xmlrsall.cpp' % XMLLOC,
d56cebe7
RD
806
807 ] + swig_sources,
808
809 include_dirs = xmlres_includes,
810 define_macros = defines,
811
812 library_dirs = libdirs,
813 libraries = libs,
814
815 extra_compile_args = cflags,
816 extra_link_args = lflags,
817 )
818
819 wxpExtensions.append(ext)
820
821
822
ebf4302c
RD
823#----------------------------------------------------------------------
824# Define the GIZMOS extension module
825#----------------------------------------------------------------------
826
827if not GL_ONLY and BUILD_GIZMOS:
828 msg('Preparing GIZMOS...')
829 location = 'contrib/gizmos'
830 GIZMOLOC = opj(location, 'contrib/src/gizmos')
831 GIZMOINC = opj(location, 'contrib/include')
832
833 swig_files = ['gizmos.i']
834
835 swig_sources = run_swig(swig_files, location, '', PKGDIR,
10ef30eb 836 USE_SWIG, swig_force, swig_args, swig_deps)
ebf4302c
RD
837
838 gizmos_includes = includes[:]
839 gizmos_includes.append(GIZMOINC)
840
841
842 # make sure local copy of contrib files are up to date
843 if IN_CVS_TREE:
844 contrib_copy_tree(opj(CTRB_INC, 'gizmos'), opj(GIZMOINC, 'wx/gizmos'))
845 contrib_copy_tree(opj(CTRB_SRC, 'gizmos'), GIZMOLOC)
846
847 ext = Extension('gizmosc', [
848 '%s/dynamicsash.cpp' % GIZMOLOC,
2f4e9287 849 '%s/editlbox.cpp' % GIZMOLOC,
950e7faf 850 #'%s/multicell.cpp' % GIZMOLOC,
ebf4302c 851 '%s/splittree.cpp' % GIZMOLOC,
950e7faf 852 '%s/ledctrl.cpp' % GIZMOLOC,
ebf4302c
RD
853 ] + swig_sources,
854
855 include_dirs = gizmos_includes,
856 define_macros = defines,
857
858 library_dirs = libdirs,
859 libraries = libs,
860
861 extra_compile_args = cflags,
862 extra_link_args = lflags,
863 )
864
865 wxpExtensions.append(ext)
866
867
868
4a61305d
RD
869#----------------------------------------------------------------------
870# Define the DLLWIDGET extension module
871#----------------------------------------------------------------------
872
873if not GL_ONLY and BUILD_DLLWIDGET:
874 msg('Preparing DLLWIDGET...')
875 location = 'contrib/dllwidget'
876 swig_files = ['dllwidget_.i']
877
878 swig_sources = run_swig(swig_files, location, '', PKGDIR,
10ef30eb 879 USE_SWIG, swig_force, swig_args, swig_deps)
4a61305d
RD
880
881 # copy a contrib project specific py module to the main package dir
882 copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0)
883
884 ext = Extension('dllwidget_c', [
885 '%s/dllwidget.cpp' % location,
886 ] + swig_sources,
887
888 include_dirs = includes,
889 define_macros = defines,
890
891 library_dirs = libdirs,
892 libraries = libs,
893
894 extra_compile_args = cflags,
895 extra_link_args = lflags,
896 )
897
898 wxpExtensions.append(ext)
899
900
8916d007
RD
901#----------------------------------------------------------------------
902# Tools and scripts
903#----------------------------------------------------------------------
904
b817523b
RD
905## TOOLS = [("wxPython/tools", glob.glob("tools/*.py")),
906## ("wxPython/tools/XRCed", glob.glob("tools/XRCed/*.py") +
907## glob.glob("tools/XRCed/*.xrc") +
908## ["tools/XRCed/CHANGES",
909## "tools/XRCed/TODO",
910## "tools/XRCed/README"]),
911## ]
8916d007
RD
912
913
2eb31f8b
RD
914if NO_SCRIPTS:
915 SCRIPTS = None
916else:
917 SCRIPTS = [opj('scripts/img2png'),
918 opj('scripts/img2xpm'),
919 opj('scripts/img2py'),
920 opj('scripts/xrced'),
921 opj('scripts/pyshell'),
922 opj('scripts/pycrust'),
923 ]
4a61305d 924
926bb76c 925
c368d904
RD
926#----------------------------------------------------------------------
927# Do the Setup/Build/Install/Whatever
928#----------------------------------------------------------------------
929
1b62f00d
RD
930if __name__ == "__main__":
931 if not GL_ONLY:
932 setup(name = PKGDIR,
933 version = VERSION,
934 description = DESCRIPTION,
935 long_description = LONG_DESCRIPTION,
936 author = AUTHOR,
937 author_email = AUTHOR_EMAIL,
938 url = URL,
e2e02194 939 license = LICENSE,
1b62f00d
RD
940
941 packages = [PKGDIR,
942 PKGDIR+'.lib',
943 PKGDIR+'.lib.editor',
2ba9346d
RD
944 PKGDIR+'.lib.mixins',
945 PKGDIR+'.lib.PyCrust',
f6f98ecc
RD
946 PKGDIR+'.tools',
947 PKGDIR+'.tools.XRCed',
1b62f00d
RD
948 ],
949
950 ext_package = PKGDIR,
951 ext_modules = wxpExtensions,
8916d007 952
f6f98ecc 953 options = { 'build' : { 'build_base' : BUILD_BASE }},
a541c325 954
8916d007 955 ##data_files = TOOLS,
b817523b 956 scripts = SCRIPTS,
1b62f00d 957 )
c368d904 958
1b62f00d 959 else:
c368d904 960
1b62f00d
RD
961 setup(name = "wxPython-gl",
962 version = VERSION,
963 description = "wxGLCanvas class for wxPython",
964 author = AUTHOR,
965 author_email = AUTHOR_EMAIL,
966 url = URL,
e2e02194 967 license = LICENSE,
c368d904 968
1b62f00d 969 py_modules = [ "wxPython.glcanvas" ],
c368d904 970
1b62f00d
RD
971 ext_package = PKGDIR,
972 ext_modules = wxpExtensions,
8916d007 973
1b62f00d 974 )
c368d904 975
c368d904
RD
976
977
978
979#----------------------------------------------------------------------
980#----------------------------------------------------------------------