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