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