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