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