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