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