]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
don't lose encoding information when getting/setting the text in the control
[wxWidgets.git] / wxPython / setup.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------
3
4 import sys, os, glob, fnmatch, commands
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 = 1
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 # Version part of wxWindows LIB/DLL names
110 WXDLLVER = '%d%d' % (VER_MAJOR, VER_MINOR)
111
112
113 #----------------------------------------------------------------------
114
115 def msg(text):
116 if __name__ == "__main__":
117 print text
118
119
120 def opj(*args):
121 path = apply(os.path.join, args)
122 return os.path.normpath(path)
123
124
125 def libFlag():
126 if FINAL:
127 rv = ''
128 elif HYBRID:
129 rv = 'h'
130 else:
131 rv = 'd'
132 if UNICODE:
133 rv = 'u' + rv
134 return rv
135
136
137 #----------------------------------------------------------------------
138 # Some other globals
139 #----------------------------------------------------------------------
140
141 PKGDIR = 'wxPython'
142 wxpExtensions = []
143 DATA_FILES = []
144
145 force = '--force' in sys.argv or '-f' in sys.argv
146 debug = '--debug' in sys.argv or '-g' in sys.argv
147
148 # change the PORT default for wxMac
149 if sys.platform[:6] == "darwin":
150 WXPORT = 'mac'
151
152 # and do the same for wxMSW, just for consistency
153 if os.name == 'nt':
154 WXPORT = 'msw'
155
156
157 #----------------------------------------------------------------------
158 # Check for build flags on the command line
159 #----------------------------------------------------------------------
160
161 # Boolean (int) flags
162 for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC',
163 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN',
164 'CORE_ONLY', 'PREP_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'UNICODE',
165 'UNDEF_NDEBUG', 'NO_SCRIPTS',
166 'FINAL', 'HYBRID', ]:
167 for x in range(len(sys.argv)):
168 if sys.argv[x].find(flag) == 0:
169 pos = sys.argv[x].find('=') + 1
170 if pos > 0:
171 vars()[flag] = eval(sys.argv[x][pos:])
172 sys.argv[x] = ''
173
174 # String options
175 for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE', 'WXPORT']:
176 for x in range(len(sys.argv)):
177 if sys.argv[x].find(option) == 0:
178 pos = sys.argv[x].find('=') + 1
179 if pos > 0:
180 vars()[option] = sys.argv[x][pos:]
181 sys.argv[x] = ''
182
183 sys.argv = filter(None, sys.argv)
184
185
186 #----------------------------------------------------------------------
187 # some helper functions
188 #----------------------------------------------------------------------
189
190 def Verify_WX_CONFIG():
191 """ Called below for the builds that need wx-config,
192 if WX_CONFIG is not set then tries to select the specific
193 wx*-config script based on build options. If not found
194 then it defaults to 'wx-config'.
195 """
196 # if WX_CONFIG hasn't been set to an explicit value then construct one.
197 global WX_CONFIG
198 if WX_CONFIG is None:
199 if debug: # TODO: Fix this. wxPython's --debug shouldn't be tied to wxWindows...
200 df = 'd'
201 else:
202 df = ''
203 if UNICODE:
204 uf = 'u'
205 else:
206 uf = ''
207 ver2 = "%s.%s" % (VER_MAJOR, VER_MINOR)
208 WX_CONFIG = 'wx%s%s%s-%s-config' % (WXPORT, uf, df, ver2)
209
210 searchpath = os.environ["PATH"]
211 for p in searchpath.split(':'):
212 fp = os.path.join(p, WX_CONFIG)
213 if os.path.exists(fp) and os.access(fp, os.X_OK):
214 # success
215 msg("Found wx-config: " + fp)
216 WX_CONFIG = fp
217 break
218 else:
219 msg("WX_CONFIG not specified and %s not found on $PATH "
220 "defaulting to \"wx-config\"" % WX_CONFIG)
221 WX_CONFIG = 'wx-config'
222
223
224
225 def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps=[]):
226 """Run SWIG the way I want it done"""
227 if not os.path.exists(os.path.join(dir, gendir)):
228 os.mkdir(os.path.join(dir, gendir))
229
230 sources = []
231
232 for file in files:
233 basefile = os.path.splitext(file)[0]
234 i_file = os.path.join(dir, file)
235 py_file = os.path.join(dir, gendir, basefile+'.py')
236 cpp_file = os.path.join(dir, gendir, basefile+'.cpp')
237
238 sources.append(cpp_file)
239
240 if USE_SWIG:
241 for dep in swig_deps:
242 if newer(dep, py_file) or newer(dep, cpp_file):
243 force = 1
244 break
245
246 if force or newer(i_file, py_file) or newer(i_file, cpp_file):
247 # we need forward slashes here even on win32
248 cpp_file = '/'.join(cpp_file.split('\\'))
249 i_file = '/'.join(i_file.split('\\'))
250
251 cmd = ['./wxSWIG/wxswig'] + swig_args + ['-I'+dir, '-c', '-o', cpp_file, i_file]
252 msg(' '.join(cmd))
253 spawn(cmd)
254
255 # copy the generated python file to the package directory
256 copy_file(py_file, package, update=not force, verbose=0)
257
258 return sources
259
260
261
262 def contrib_copy_tree(src, dest, verbose=0):
263 """Update local copies of wxWindows contrib files"""
264 from distutils.dir_util import mkpath, copy_tree
265
266 mkpath(dest, verbose=verbose)
267 copy_tree(src, dest, update=1, verbose=verbose)
268
269
270
271 class smart_install_data(install_data):
272 def run(self):
273 #need to change self.install_dir to the actual library dir
274 install_cmd = self.get_finalized_command('install')
275 self.install_dir = getattr(install_cmd, 'install_lib')
276 return install_data.run(self)
277
278
279 def build_locale_dir(destdir, verbose=1):
280 """Build a locale dir under the wxPython package for MSW"""
281 moFiles = glob.glob(opj(WXDIR, 'locale', '*.mo'))
282 for src in moFiles:
283 lang = os.path.splitext(os.path.basename(src))[0]
284 dest = opj(destdir, lang, 'LC_MESSAGES')
285 mkpath(dest, verbose=verbose)
286 copy_file(src, opj(dest, 'wxstd.mo'), update=1, verbose=verbose)
287
288
289 def build_locale_list(srcdir):
290 # get a list of all files under the srcdir, to be used for install_data
291 def walk_helper(lst, dirname, files):
292 for f in files:
293 filename = opj(dirname, f)
294 if not os.path.isdir(filename):
295 lst.append( (dirname, [filename]) )
296 file_list = []
297 os.path.walk(srcdir, walk_helper, file_list)
298 return file_list
299
300
301 def find_data_files(srcdir, *wildcards):
302 # get a list of all files under the srcdir matching wildcards,
303 # returned in a format to be used for install_data
304
305 def walk_helper(arg, dirname, files):
306 names = []
307 lst, wildcards = arg
308 for wc in wildcards:
309 for f in files:
310 filename = opj(dirname, f)
311 if fnmatch.fnmatch(filename, wc) and not os.path.isdir(filename):
312 names.append(filename)
313 if names:
314 lst.append( (dirname, names ) )
315
316 file_list = []
317 os.path.walk(srcdir, walk_helper, (file_list, wildcards))
318 return file_list
319
320
321 def makeLibName(name):
322 if os.name == 'posix':
323 libname = '%s_%s-%s' % (WXBASENAME, name, WXRELEASE)
324 else:
325 libname = 'wxmsw%s%s_%s' % (WXDLLVER, libFlag(), name)
326
327 return [libname]
328
329
330
331 def adjustCFLAGS(cflags, defines, includes):
332 '''Extract 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 '''Extract 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_dll', 'msw' + libFlag()),
406 opj(WXDIR, 'include'),
407 opj(WXDIR, 'contrib', 'include'),
408 ]
409
410 defines = [ ('WIN32', None),
411 ('_WINDOWS', None),
412
413 (WXPLAT, None),
414 ('WXUSINGDLL', '1'),
415
416 ('SWIG_GLOBAL', None),
417 ('HAVE_CONFIG_H', None),
418 ('WXP_USE_THREAD', '1'),
419 ]
420
421 if UNDEF_NDEBUG:
422 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
423
424
425 if not FINAL or HYBRID:
426 defines.append( ('__WXDEBUG__', None) )
427
428 libdirs = [ opj(WXDIR, 'lib', 'vc_dll') ]
429 libs = [ 'wxbase' + WXDLLVER + libFlag(), # TODO: trim this down to what is really needed for the core
430 'wxbase' + WXDLLVER + libFlag() + '_net',
431 'wxbase' + WXDLLVER + libFlag() + '_xml',
432 makeLibName('core')[0],
433 makeLibName('adv')[0],
434 makeLibName('html')[0],
435 ]
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 else:
483 cflags.append('-O3')
484
485 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
486 lflags = lflags.split()
487
488 WXBASENAME = os.popen(WX_CONFIG + ' --basename').read()[:-1]
489 WXRELEASE = os.popen(WX_CONFIG + ' --release').read()[:-1]
490 WXPREFIX = os.popen(WX_CONFIG + ' --prefix').read()[:-1]
491
492
493 if sys.platform[:6] == "darwin":
494 # Flags and such for a Darwin (Max OS X) build of Python
495 WXPLAT = '__WXMAC__'
496 GENDIR = 'mac'
497 libs = ['stdc++']
498 NO_SCRIPTS = 1
499
500
501 else:
502 # Set flags for other Unix type platforms
503 GENDIR = WXPORT
504
505 if WXPORT == 'gtk':
506 WXPLAT = '__WXGTK__'
507 portcfg = os.popen('gtk-config --cflags', 'r').read()[:-1]
508 elif WXPORT == 'gtk2':
509 WXPLAT = '__WXGTK__'
510 GENDIR = 'gtk' # no code differences so use the same generated sources
511 portcfg = os.popen('pkg-config gtk+-2.0 --cflags', 'r').read()[:-1]
512 BUILD_BASE = BUILD_BASE + '-' + WXPORT
513 elif WXPORT == 'x11':
514 WXPLAT = '__WXX11__'
515 portcfg = ''
516 BUILD_BASE = BUILD_BASE + '-' + WXPORT
517 else:
518 raise SystemExit, "Unknown WXPORT value: " + WXPORT
519
520 cflags += portcfg.split()
521
522 # If you get unresolved symbol errors on Solaris and are using gcc, then
523 # uncomment this block to add the right flags to the link step and build
524 # again.
525 ## if os.uname()[0] == 'SunOS':
526 ## libs.append('gcc')
527 ## libdirs.append(commands.getoutput("gcc -print-search-dirs | grep '^install' | awk '{print $2}'")[:-1])
528
529
530 # Move the various -I, -D, etc. flags we got from the *config scripts
531 # into the distutils lists.
532 cflags = adjustCFLAGS(cflags, defines, includes)
533 lflags = adjustLFLAGS(lflags, libdirs, libs)
534
535
536 #----------------------------------------------------------------------
537 else:
538 raise 'Sorry Charlie, platform not supported...'
539
540
541 #----------------------------------------------------------------------
542 # post platform setup checks and tweaks, create the full version string
543 #----------------------------------------------------------------------
544
545 if UNICODE:
546 BUILD_BASE = BUILD_BASE + '.unicode'
547 VER_FLAGS += 'u'
548
549
550 VERSION = "%s.%s.%s.%s%s" % (VER_MAJOR, VER_MINOR, VER_RELEASE,
551 VER_SUBREL, VER_FLAGS)
552
553 #----------------------------------------------------------------------
554 # Update the version file
555 #----------------------------------------------------------------------
556
557 # Unconditionally updated since the version string can change based
558 # on the UNICODE flag
559 open('src/__version__.py', 'w').write("""\
560 # This file was generated by setup.py...
561
562 wxVERSION_STRING = '%(VERSION)s'
563 wxMAJOR_VERSION = %(VER_MAJOR)s
564 wxMINOR_VERSION = %(VER_MINOR)s
565 wxRELEASE_VERSION = %(VER_RELEASE)s
566 wxSUBREL_VERSION = %(VER_SUBREL)s
567
568 wxVERSION = (wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_VERSION,
569 wxSUBREL_VERSION, '%(VER_FLAGS)s')
570
571 wxRELEASE_NUMBER = wxRELEASE_VERSION # for compatibility
572 """ % globals())
573
574
575
576
577 #----------------------------------------------------------------------
578 # SWIG defaults
579 #----------------------------------------------------------------------
580
581 swig_force = force
582 swig_args = ['-c++', '-shadow', '-python', '-keyword',
583 '-dnone',
584 #'-dascii',
585 #'-docstring', '-Sbefore',
586 '-I./src', '-D'+WXPLAT,
587 ]
588 if UNICODE:
589 swig_args.append('-DwxUSE_UNICODE')
590
591 swig_deps = ['src/my_typemaps.i']
592
593
594 #----------------------------------------------------------------------
595 # Define the CORE extension module
596 #----------------------------------------------------------------------
597
598 msg('Preparing CORE...')
599 swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
600 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
601 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
602 'printfw.i', 'sizers.i', 'clip_dnd.i',
603 'filesys.i', 'streams.i', 'utils.i', 'fonts.i'
604 ]
605
606 swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
607 USE_SWIG, swig_force, swig_args, swig_deps)
608
609 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
610 copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
611
612
613 if IN_CVS_TREE: # update the license files
614 mkpath('licence')
615 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
616 copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0)
617
618
619 if os.name == 'nt':
620 build_locale_dir(opj(PKGDIR, 'locale'))
621 DATA_FILES += build_locale_list(opj(PKGDIR, 'locale'))
622
623
624 if os.name == 'nt':
625 rc_file = ['src/wxc.rc']
626 else:
627 rc_file = []
628
629
630 ext = Extension('wxc', ['src/helpers.cpp',
631 'src/drawlist.cpp',
632 'src/libpy.c',
633 ] + rc_file + swig_sources,
634
635 include_dirs = includes,
636 define_macros = defines,
637
638 library_dirs = libdirs,
639 libraries = libs,
640
641 extra_compile_args = cflags,
642 extra_link_args = lflags,
643 )
644 wxpExtensions.append(ext)
645
646
647 # Extension for the grid module
648 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
649 USE_SWIG, swig_force, swig_args, swig_deps)
650 ext = Extension('gridc', swig_sources,
651 include_dirs = includes,
652 define_macros = defines,
653 library_dirs = libdirs,
654 libraries = libs,
655 extra_compile_args = cflags,
656 extra_link_args = lflags,
657 )
658 wxpExtensions.append(ext)
659
660
661 # Extension for the html modules
662 swig_sources = run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR, PKGDIR,
663 USE_SWIG, swig_force, swig_args, swig_deps)
664 ext = Extension('htmlc', swig_sources,
665 include_dirs = includes,
666 define_macros = defines,
667 library_dirs = libdirs,
668 libraries = libs,
669 extra_compile_args = cflags,
670 extra_link_args = lflags,
671 )
672 wxpExtensions.append(ext)
673
674
675 # Extension for the calendar module
676 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
677 USE_SWIG, swig_force, swig_args, swig_deps)
678 ext = Extension('calendarc', swig_sources,
679 include_dirs = includes,
680 define_macros = defines,
681 library_dirs = libdirs,
682 libraries = libs,
683 extra_compile_args = cflags,
684 extra_link_args = lflags,
685 )
686 wxpExtensions.append(ext)
687
688
689 # Extension for the help module
690 swig_sources = run_swig(['help.i'], 'src', GENDIR, PKGDIR,
691 USE_SWIG, swig_force, swig_args, swig_deps)
692 ext = Extension('helpc', swig_sources,
693 include_dirs = includes,
694 define_macros = defines,
695 library_dirs = libdirs,
696 libraries = libs,
697 extra_compile_args = cflags,
698 extra_link_args = lflags,
699 )
700 wxpExtensions.append(ext)
701
702
703 # Extension for the wizard module
704 swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR,
705 USE_SWIG, swig_force, swig_args, swig_deps)
706 ext = Extension('wizardc', swig_sources,
707 include_dirs = includes,
708 define_macros = defines,
709 library_dirs = libdirs,
710 libraries = libs,
711 extra_compile_args = cflags,
712 extra_link_args = lflags,
713 )
714 wxpExtensions.append(ext)
715
716
717 #----------------------------------------------------------------------
718 # Define the GLCanvas extension module
719 #----------------------------------------------------------------------
720
721 if BUILD_GLCANVAS:
722 msg('Preparing GLCANVAS...')
723 location = 'contrib/glcanvas'
724 swig_files = ['glcanvas.i']
725
726 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
727 USE_SWIG, swig_force, swig_args, swig_deps)
728
729 gl_libs = []
730 if os.name == 'posix':
731 gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
732 gl_lflags = gl_config.split() + lflags
733 gl_libs = libs
734 else:
735 gl_libs = libs + ['opengl32', 'glu32'] + makeLibName('gl')
736 gl_lflags = lflags
737
738 ext = Extension('glcanvasc',
739 swig_sources,
740
741 include_dirs = includes,
742 define_macros = defines,
743
744 library_dirs = libdirs,
745 libraries = gl_libs,
746
747 extra_compile_args = cflags,
748 extra_link_args = gl_lflags,
749 )
750
751 wxpExtensions.append(ext)
752
753
754 #----------------------------------------------------------------------
755 # Define the OGL extension module
756 #----------------------------------------------------------------------
757
758 if BUILD_OGL:
759 msg('Preparing OGL...')
760 location = 'contrib/ogl'
761
762 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
763 'oglcanvas.i']
764
765 swig_sources = run_swig(swig_files, location, '', PKGDIR,
766 USE_SWIG, swig_force, swig_args, swig_deps)
767
768 ext = Extension('oglc',
769 swig_sources,
770
771 include_dirs = includes,
772 define_macros = defines + [('wxUSE_DEPRECATED', '0')],
773
774 library_dirs = libdirs,
775 libraries = libs + makeLibName('ogl'),
776
777 extra_compile_args = cflags,
778 extra_link_args = lflags,
779 )
780
781 wxpExtensions.append(ext)
782
783
784
785 #----------------------------------------------------------------------
786 # Define the STC extension module
787 #----------------------------------------------------------------------
788
789 if BUILD_STC:
790 msg('Preparing STC...')
791 location = 'contrib/stc'
792 if os.name == 'nt':
793 STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
794 else:
795 STC_H = opj(WXPREFIX, 'include/wx/stc')
796
797 ## NOTE: need to add this to the stc.bkl...
798
799 ## # Check if gen_iface needs to be run for the wxSTC sources
800 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
801 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
802 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
803
804 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
805 ## cwd = os.getcwd()
806 ## os.chdir(opj(CTRB_SRC, 'stc'))
807 ## sys.path.insert(0, os.curdir)
808 ## import gen_iface
809 ## gen_iface.main([])
810 ## os.chdir(cwd)
811
812
813 swig_files = ['stc_.i']
814 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
815 USE_SWIG, swig_force,
816 swig_args + ['-I'+STC_H, '-I'+location],
817 [opj(STC_H, 'stc.h')] + swig_deps)
818
819 # copy a contrib project specific py module to the main package dir
820 copy_file(opj(location, 'stc.py'), PKGDIR, update=1, verbose=0)
821
822 ext = Extension('stc_c',
823 swig_sources,
824
825 include_dirs = includes,
826 define_macros = defines,
827
828 library_dirs = libdirs,
829 libraries = libs + makeLibName('stc'),
830
831 extra_compile_args = cflags,
832 extra_link_args = lflags,
833 )
834
835 wxpExtensions.append(ext)
836
837
838
839 #----------------------------------------------------------------------
840 # Define the IEWIN extension module (experimental)
841 #----------------------------------------------------------------------
842
843 if BUILD_IEWIN:
844 msg('Preparing IEWIN...')
845 location = 'contrib/iewin'
846
847 swig_files = ['iewin.i', ]
848
849 swig_sources = run_swig(swig_files, location, '', PKGDIR,
850 USE_SWIG, swig_force, swig_args, swig_deps)
851
852
853 ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location,
854 '%s/wxactivex.cpp' % location,
855 ] + swig_sources,
856
857 include_dirs = includes,
858 define_macros = 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 # Define the XRC extension module
872 #----------------------------------------------------------------------
873
874 if BUILD_XRC:
875 msg('Preparing XRC...')
876 location = 'contrib/xrc'
877
878 swig_files = ['xrc.i']
879 swig_sources = run_swig(swig_files, location, '', PKGDIR,
880 USE_SWIG, swig_force, swig_args, swig_deps)
881
882 ext = Extension('xrcc',
883 swig_sources,
884
885 include_dirs = includes,
886 define_macros = defines,
887
888 library_dirs = libdirs,
889 libraries = libs + makeLibName('xrc'),
890
891 extra_compile_args = cflags,
892 extra_link_args = lflags,
893 )
894
895 wxpExtensions.append(ext)
896
897
898
899 #----------------------------------------------------------------------
900 # Define the GIZMOS extension module
901 #----------------------------------------------------------------------
902
903 if BUILD_GIZMOS:
904 msg('Preparing GIZMOS...')
905 location = 'contrib/gizmos'
906
907 swig_files = ['gizmos.i']
908 swig_sources = run_swig(swig_files, location, '', PKGDIR,
909 USE_SWIG, swig_force, swig_args, swig_deps)
910
911 ext = Extension('gizmosc',
912 [ '%s/treelistctrl.cpp' % location ] + swig_sources,
913
914 include_dirs = includes,
915 define_macros = defines,
916
917 library_dirs = libdirs,
918 libraries = libs + makeLibName('gizmos'),
919
920 extra_compile_args = cflags,
921 extra_link_args = lflags,
922 )
923
924 wxpExtensions.append(ext)
925
926
927
928 #----------------------------------------------------------------------
929 # Define the DLLWIDGET extension module
930 #----------------------------------------------------------------------
931
932 if BUILD_DLLWIDGET:
933 msg('Preparing DLLWIDGET...')
934 location = 'contrib/dllwidget'
935 swig_files = ['dllwidget_.i']
936
937 swig_sources = run_swig(swig_files, location, '', PKGDIR,
938 USE_SWIG, swig_force, swig_args, swig_deps)
939
940 # copy a contrib project specific py module to the main package dir
941 copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0)
942
943 ext = Extension('dllwidget_c', [
944 '%s/dllwidget.cpp' % location,
945 ] + swig_sources,
946
947 include_dirs = includes,
948 define_macros = defines,
949
950 library_dirs = libdirs,
951 libraries = libs,
952
953 extra_compile_args = cflags,
954 extra_link_args = lflags,
955 )
956
957 wxpExtensions.append(ext)
958
959
960
961
962 #----------------------------------------------------------------------
963 # Tools and scripts
964 #----------------------------------------------------------------------
965
966 if NO_SCRIPTS:
967 SCRIPTS = None
968 else:
969 SCRIPTS = [opj('scripts/helpviewer'),
970 opj('scripts/img2png'),
971 opj('scripts/img2xpm'),
972 opj('scripts/img2py'),
973 opj('scripts/xrced'),
974 opj('scripts/pyshell'),
975 opj('scripts/pycrust'),
976 opj('scripts/pywrap'),
977 opj('scripts/pywrap'),
978 opj('scripts/pyalacarte'),
979 opj('scripts/pyalamode'),
980 ]
981
982
983 DATA_FILES += find_data_files('wxPython/tools/XRCed', '*.txt', '*.xrc')
984 DATA_FILES += find_data_files('wxPython/py', '*.txt', '*.ico', '*.css', '*.html')
985 DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html')
986
987
988 #----------------------------------------------------------------------
989 # Do the Setup/Build/Install/Whatever
990 #----------------------------------------------------------------------
991
992 if __name__ == "__main__":
993 if not PREP_ONLY:
994 setup(name = PKGDIR,
995 version = VERSION,
996 description = DESCRIPTION,
997 long_description = LONG_DESCRIPTION,
998 author = AUTHOR,
999 author_email = AUTHOR_EMAIL,
1000 url = URL,
1001 license = LICENSE,
1002
1003 packages = ['wxPython',
1004 'wxPython.lib',
1005 'wxPython.lib.colourchooser',
1006 'wxPython.lib.editor',
1007 'wxPython.lib.mixins',
1008 'wxPython.lib.PyCrust',
1009 'wxPython.py',
1010 'wxPython.py.wxd',
1011 'wxPython.tools',
1012 'wxPython.tools.XRCed',
1013
1014 'wx',
1015 'wx.lib',
1016 'wx.lib.colourchooser',
1017 'wx.lib.editor',
1018 'wx.lib.mixins',
1019 'wx.py',
1020 'wx.tools',
1021 'wx.tools.XRCed',
1022 ],
1023
1024 ext_package = PKGDIR,
1025 ext_modules = wxpExtensions,
1026
1027 options = { 'build' : { 'build_base' : BUILD_BASE }},
1028
1029 scripts = SCRIPTS,
1030
1031 cmdclass = { 'install_data': smart_install_data},
1032 data_files = DATA_FILES,
1033
1034 )
1035
1036
1037 #----------------------------------------------------------------------
1038 #----------------------------------------------------------------------