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