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