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