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