]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
use default window id
[wxWidgets.git] / wxPython / setup.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------
3
4 import sys, os, glob, fnmatch, tempfile
5 from distutils.core import setup, Extension
6 from distutils.file_util import copy_file
7 from distutils.dir_util import mkpath
8 from distutils.dep_util import newer
9 from distutils.spawn import spawn
10
11 import distutils.command.install_data
12 import distutils.command.clean
13
14 #----------------------------------------------------------------------
15 # flags and values that affect this script
16 #----------------------------------------------------------------------
17
18 VER_MAJOR = 2 # The first three must match wxWidgets
19 VER_MINOR = 5
20 VER_RELEASE = 1
21 VER_SUBREL = 2 # wxPython release num for x.y.z release of wxWidgets
22 VER_FLAGS = "p" # release flags, such as prerelease num, unicode, etc.
23
24 DESCRIPTION = "Cross platform GUI toolkit for Python"
25 AUTHOR = "Robin Dunn"
26 AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>"
27 URL = "http://wxPython.org/"
28 DOWNLOAD_URL = "http://wxPython.org/download.php"
29 LICENSE = "wxWidgets Library License (LGPL derivative)"
30 PLATFORMS = "WIN32,OSX,POSIX"
31 KEYWORDS = "GUI,wx,wxWindows,wxWidgetscross-platform"
32
33 LONG_DESCRIPTION = """\
34 wxPython is a GUI toolkit for Python that is a wrapper around the
35 wxWidgets C++ GUI library. wxPython provides a large variety of
36 window types and controls, all implemented with a native look and
37 feel (by using the native widgets) on the platforms it is supported
38 on.
39 """
40
41 CLASSIFIERS = """\
42 Development Status :: 6 - Mature
43 Environment :: MacOS X :: Carbon
44 Environment :: Win32 (MS Windows)
45 Environment :: X11 Applications :: GTK
46 Intended Audience :: Developers
47 License :: OSI Approved
48 Operating System :: MacOS :: MacOS X
49 Operating System :: Microsoft :: Windows :: Windows 95/98/2000
50 Operating System :: POSIX
51 Programming Language :: Python
52 Topic :: Software Development :: User Interfaces
53 """
54
55 ## License :: OSI Approved :: wxWidgets Library Licence
56
57
58 # Config values below this point can be reset on the setup.py command line.
59
60 BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module
61 BUILD_OGL = 1 # If true, build the contrib/ogl extension module
62 BUILD_STC = 1 # If true, build the contrib/stc extension module
63 BUILD_XRC = 1 # XML based resource system
64 BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library
65 BUILD_DLLWIDGET = 0# Build a module that enables unknown wx widgets
66 # to be loaded from a DLL and to be used from Python.
67
68 # Internet Explorer wrapper (experimental)
69 BUILD_IEWIN = (os.name == 'nt')
70
71
72 CORE_ONLY = 0 # if true, don't build any of the above
73
74 PREP_ONLY = 0 # Only run the prepatory steps, not the actual build.
75
76 USE_SWIG = 0 # Should we actually execute SWIG, or just use the
77 # files already in the distribution?
78
79 SWIG = "swig" # The swig executable to use.
80
81 BUILD_RENAMERS = 1 # Should we build the renamer modules too?
82
83 UNICODE = 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.
86
87 UNDEF_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
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
93 # on then you end up with mismatched class structures,
94 # and wxPython will crash.
95
96 NO_SCRIPTS = 0 # Don't install the tool scripts
97
98 WX_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
105 WXPORT = 'gtk' # On Linux/Unix there are several ports of wxWidgets available.
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
110 BUILD_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
115
116 CONTRIBS_INC = "" # A dir to add as an -I flag when compiling the contribs
117
118
119 # Some MSW build settings
120
121 FINAL = 0 # Mirrors use of same flag in wx makefiles,
122 # (0 or 1 only) should probably find a way to
123 # autodetect this...
124
125 HYBRID = 1 # If set and not debug or FINAL, then build a
126 # hybrid extension that can be used by the
127 # non-debug version of python, but contains
128 # debugging symbols for wxWidgets and wxPython.
129 # wxWidgets must have been built with /MD, not /MDd
130 # (using FINAL=hybrid will do it.)
131
132 # Version part of wxWidgets LIB/DLL names
133 WXDLLVER = '%d%d' % (VER_MAJOR, VER_MINOR)
134
135
136 #----------------------------------------------------------------------
137
138 def msg(text):
139 if __name__ == "__main__":
140 print text
141
142
143 def opj(*args):
144 path = apply(os.path.join, args)
145 return os.path.normpath(path)
146
147
148 def libFlag():
149 if FINAL:
150 rv = ''
151 elif HYBRID:
152 rv = 'h'
153 else:
154 rv = 'd'
155 if UNICODE:
156 rv = 'u' + rv
157 return rv
158
159
160 #----------------------------------------------------------------------
161 # Some other globals
162 #----------------------------------------------------------------------
163
164 PKGDIR = 'wx'
165 wxpExtensions = []
166 DATA_FILES = []
167 CLEANUP = []
168
169 force = '--force' in sys.argv or '-f' in sys.argv
170 debug = '--debug' in sys.argv or '-g' in sys.argv
171 cleaning = 'clean' in sys.argv
172
173
174 # change the PORT default for wxMac
175 if sys.platform[:6] == "darwin":
176 WXPORT = 'mac'
177
178 # and do the same for wxMSW, just for consistency
179 if os.name == 'nt':
180 WXPORT = 'msw'
181
182
183 #----------------------------------------------------------------------
184 # Check for build flags on the command line
185 #----------------------------------------------------------------------
186
187 # Boolean (int) flags
188 for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC',
189 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN',
190 'CORE_ONLY', 'PREP_ONLY', 'USE_SWIG', 'UNICODE',
191 'UNDEF_NDEBUG', 'NO_SCRIPTS', 'BUILD_RENAMERS',
192 'FINAL', 'HYBRID', ]:
193 for x in range(len(sys.argv)):
194 if sys.argv[x].find(flag) == 0:
195 pos = sys.argv[x].find('=') + 1
196 if pos > 0:
197 vars()[flag] = eval(sys.argv[x][pos:])
198 sys.argv[x] = ''
199
200 # String options
201 for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE', 'WXPORT', 'SWIG',
202 'CONTRIBS_INC']:
203 for x in range(len(sys.argv)):
204 if sys.argv[x].find(option) == 0:
205 pos = sys.argv[x].find('=') + 1
206 if pos > 0:
207 vars()[option] = sys.argv[x][pos:]
208 sys.argv[x] = ''
209
210 sys.argv = filter(None, sys.argv)
211
212
213 #----------------------------------------------------------------------
214 # some helper functions
215 #----------------------------------------------------------------------
216
217 def 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:
226 if debug: # TODO: Fix this. wxPython's --debug shouldn't be tied to wxWidgets...
227 df = 'd'
228 else:
229 df = ''
230 if UNICODE:
231 uf = 'u'
232 else:
233 uf = ''
234 ver2 = "%s.%s" % (VER_MAJOR, VER_MINOR)
235 port = WXPORT
236 if port == "x11":
237 port = "x11univ"
238 WX_CONFIG = 'wx%s%s%s-%s-config' % (port, uf, df, ver2)
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
255 def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps=[]):
256 """Run SWIG the way I want it done"""
257
258 if USE_SWIG and not os.path.exists(os.path.join(dir, gendir)):
259 os.mkdir(os.path.join(dir, gendir))
260
261 if USE_SWIG and not os.path.exists(os.path.join("docs", "xml-raw")):
262 os.mkdir(os.path.join("docs", "xml-raw"))
263
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')
270 cpp_file = os.path.join(dir, gendir, basefile+'_wrap.cpp')
271 xml_file = os.path.join("docs", "xml-raw", basefile+'_swig.xml')
272
273 sources.append(cpp_file)
274
275 if not cleaning and USE_SWIG:
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):
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:
287 #tempfile.tempdir = sourcePath
288 xmltemp = tempfile.mktemp('.xml')
289
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 + \
294 [ '-DBUILDING_RENAMERS', '-xmlout', xmltemp ] + \
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
300 cmd = [ sys.executable, '-u',
301 './distrib/build_renamers.py', dir, basefile, xmltemp]
302 msg(' '.join(cmd))
303 spawn(cmd)
304 os.remove(xmltemp)
305
306 # Then run swig for real
307 cmd = [ swig_cmd ] + swig_args + ['-I'+dir, '-o', cpp_file,
308 '-xmlout', xml_file, i_file]
309 msg(' '.join(cmd))
310 spawn(cmd)
311
312
313 # copy the generated python file to the package directory
314 copy_file(py_file, package, update=not force, verbose=0)
315 CLEANUP.append(opj(package, os.path.basename(py_file)))
316
317 return sources
318
319
320
321 # Specializations of some distutils command classes
322 class 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
329
330 class 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)
355
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)
363
364
365
366
367 def 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)
375 CLEANUP.append(opj(dest, 'wxstd.mo'))
376 CLEANUP.append(dest)
377
378
379 def 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
391 def 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
409
410
411 def makeLibName(name):
412 if os.name == 'posix':
413 libname = '%s_%s-%s' % (WXBASENAME, name, WXRELEASE)
414 else:
415 libname = 'wxmsw%s%s_%s' % (WXDLLVER, libFlag(), name)
416
417 return [libname]
418
419
420
421 def adjustCFLAGS(cflags, defines, includes):
422 '''Extrace the raw -I, -D, and -U flags and put them into
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
442 def adjustLFLAGS(lfags, libdirs, libs):
443 '''Extrace the -L and -l flags and put them in libdirs and libs as needed'''
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
454
455 #----------------------------------------------------------------------
456 # sanity checks
457
458 if CORE_ONLY:
459 BUILD_GLCANVAS = 0
460 BUILD_OGL = 0
461 BUILD_STC = 0
462 BUILD_XRC = 0
463 BUILD_GIZMOS = 0
464 BUILD_DLLWIDGET = 0
465 BUILD_IEWIN = 0
466
467 if debug:
468 FINAL = 0
469 HYBRID = 0
470
471 if FINAL:
472 HYBRID = 0
473
474 if UNICODE and WXPORT not in ['msw', 'gtk2']:
475 raise SystemExit, "UNICODE mode not currently supported on this WXPORT: "+WXPORT
476
477
478 #----------------------------------------------------------------------
479 # Setup some platform specific stuff
480 #----------------------------------------------------------------------
481
482 if os.name == 'nt':
483 # Set compile flags and such for MSVC. These values are derived
484 # from the wxWidgets makefiles for MSVC, other compilers settings
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
491 WXPLAT = '__WXMSW__'
492 GENDIR = 'msw'
493
494 includes = ['include', 'src',
495 opj(WXDIR, 'lib', 'vc_dll', 'msw' + libFlag()),
496 opj(WXDIR, 'include'),
497 opj(WXDIR, 'contrib', 'include'),
498 ]
499
500 defines = [ ('WIN32', None),
501 ('_WINDOWS', None),
502
503 (WXPLAT, None),
504 ('WXUSINGDLL', '1'),
505
506 ('SWIG_GLOBAL', None),
507 ('WXP_USE_THREAD', '1'),
508 ]
509
510 if UNDEF_NDEBUG:
511 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
512
513 if HYBRID:
514 defines.append( ('__NO_VC_CRTDBG__', None) )
515
516 if not FINAL or HYBRID:
517 defines.append( ('__WXDEBUG__', None) )
518
519 libdirs = [ opj(WXDIR, 'lib', 'vc_dll') ]
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 ]
527
528 libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
529 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
530 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
531 'advapi32', 'wsock32']
532
533
534 cflags = [ '/Gy',
535 # '/GX-' # workaround for internal compiler error in MSVC on some machines
536 ]
537 lflags = None
538
539 # Other MSVC flags...
540 # Too bad I don't remember why I was playing with these, can they be removed?
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', ]
548
549
550
551 #----------------------------------------------------------------------
552
553 elif os.name == 'posix':
554 WXDIR = '..'
555 includes = ['include', 'src']
556 defines = [('SWIG_GLOBAL', None),
557 ('HAVE_CONFIG_H', None),
558 ('WXP_USE_THREAD', '1'),
559 ]
560 if UNDEF_NDEBUG:
561 defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef
562
563 Verify_WX_CONFIG()
564
565 libdirs = []
566 libs = []
567
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
575 cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1]
576 cflags = cflags.split()
577 if debug:
578 cflags.append('-g')
579 cflags.append('-O0')
580 else:
581 cflags.append('-O3')
582
583 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
584 lflags = lflags.split()
585
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]
589
590
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
597
598
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
617
618 cflags += portcfg.split()
619
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")
625
626
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)
631
632
633 #----------------------------------------------------------------------
634 else:
635 raise 'Sorry, platform not supported...'
636
637
638 #----------------------------------------------------------------------
639 # post platform setup checks and tweaks, create the full version string
640 #----------------------------------------------------------------------
641
642 if UNICODE:
643 BUILD_BASE = BUILD_BASE + '.unicode'
644 VER_FLAGS += 'u'
645
646
647 VERSION = "%s.%s.%s.%s%s" % (VER_MAJOR, VER_MINOR, VER_RELEASE,
648 VER_SUBREL, VER_FLAGS)
649
650 #----------------------------------------------------------------------
651 # Update the version file
652 #----------------------------------------------------------------------
653
654 # Unconditionally updated since the version string can change based
655 # on the UNICODE flag
656 open('wx/__version__.py', 'w').write("""\
657 # This file was generated by setup.py...
658
659 VERSION_STRING = '%(VERSION)s'
660 MAJOR_VERSION = %(VER_MAJOR)s
661 MINOR_VERSION = %(VER_MINOR)s
662 RELEASE_VERSION = %(VER_RELEASE)s
663 SUBREL_VERSION = %(VER_SUBREL)s
664
665 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
666 SUBREL_VERSION, '%(VER_FLAGS)s')
667
668 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
669 """ % globals())
670
671 CLEANUP.append('wx/__version__.py')
672
673
674
675 #----------------------------------------------------------------------
676 # SWIG defaults
677 #----------------------------------------------------------------------
678
679 swig_cmd = SWIG
680 swig_force = force
681 swig_args = ['-c++',
682 '-Wall',
683 '-nodefault',
684
685 '-python',
686 '-keyword',
687 '-new_repr',
688 '-modern',
689
690 '-I./src',
691 '-D'+WXPLAT,
692 '-noruntime'
693 ]
694 if UNICODE:
695 swig_args.append('-DwxUSE_UNICODE')
696
697 swig_deps = [ 'src/my_typemaps.i',
698 'src/common.swg',
699 'src/pyrun.swg',
700 ]
701
702 depends = [ #'include/wx/wxPython/wxPython.h',
703 #'include/wx/wxPython/wxPython_int.h',
704 #'src/pyclasses.h',
705 ]
706
707
708 #----------------------------------------------------------------------
709 # Define the CORE extension module
710 #----------------------------------------------------------------------
711
712 msg('Preparing CORE...')
713 swig_sources = run_swig(['core.i'], 'src', GENDIR, PKGDIR,
714 USE_SWIG, swig_force, swig_args, swig_deps +
715 [ 'src/_accel.i',
716 'src/_app.i',
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',
737 'src/_control.i',
738 ])
739
740 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
741 CLEANUP.append(opj(PKGDIR, '__init__.py'))
742
743
744 # update the license files
745 mkpath('licence')
746 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
747 copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0)
748 CLEANUP.append(opj('licence',file))
749 CLEANUP.append('licence')
750
751
752 if os.name == 'nt':
753 build_locale_dir(opj(PKGDIR, 'locale'))
754 DATA_FILES += build_locale_list(opj(PKGDIR, 'locale'))
755
756
757 if os.name == 'nt':
758 rc_file = ['src/wxc.rc']
759 else:
760 rc_file = []
761
762
763 ext = Extension('_core', ['src/helpers.cpp',
764 'src/libpy.c',
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,
775
776 depends = depends
777 )
778 wxpExtensions.append(ext)
779
780
781
782
783
784 # Extension for the GDI module
785 swig_sources = run_swig(['gdi.i'], 'src', GENDIR, PKGDIR,
786 USE_SWIG, swig_force, swig_args, swig_deps +
787 ['src/_gdi_rename.i',
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',
795 'src/_effects.i',
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 ])
805 ext = Extension('_gdi', ['src/drawlist.cpp'] + swig_sources,
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,
812 depends = depends
813 )
814 wxpExtensions.append(ext)
815
816
817
818
819
820
821 # Extension for the windows module
822 swig_sources = run_swig(['windows.i'], 'src', GENDIR, PKGDIR,
823 USE_SWIG, swig_force, swig_args, swig_deps +
824 ['src/_windows_rename.i',
825 'src/_windows_reverse.txt',
826 'src/_panel.i',
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 ])
840 ext = Extension('_windows', swig_sources,
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,
847 depends = depends
848 )
849 wxpExtensions.append(ext)
850
851
852
853
854 # Extension for the controls module
855 swig_sources = run_swig(['controls.i'], 'src', GENDIR, PKGDIR,
856 USE_SWIG, swig_force, swig_args, swig_deps +
857 [ 'src/_controls_rename.i',
858 'src/_controls_reverse.txt',
859 'src/_toolbar.i',
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',
880 ])
881 ext = 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 )
890 wxpExtensions.append(ext)
891
892
893
894
895 # Extension for the misc module
896 swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR,
897 USE_SWIG, swig_force, swig_args, swig_deps +
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',
914 'src/_clipbrd.i',
915 ])
916 ext = 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 )
925 wxpExtensions.append(ext)
926
927
928
929 ##
930 ## Core modules that are not in the "core" namespace start here
931 ##
932
933 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
934 USE_SWIG, swig_force, swig_args, swig_deps)
935 ext = 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 )
944 wxpExtensions.append(ext)
945
946
947 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
948 USE_SWIG, swig_force, swig_args, swig_deps)
949 ext = Extension('_grid', swig_sources,
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,
956 depends = depends
957 )
958 wxpExtensions.append(ext)
959
960
961
962 swig_sources = run_swig(['html.i'], 'src', GENDIR, PKGDIR,
963 USE_SWIG, swig_force, swig_args, swig_deps)
964 ext = Extension('_html', swig_sources,
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,
971 depends = depends
972 )
973 wxpExtensions.append(ext)
974
975
976
977 swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR,
978 USE_SWIG, swig_force, swig_args, swig_deps)
979 ext = Extension('_wizard', swig_sources,
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,
986 depends = depends
987 )
988 wxpExtensions.append(ext)
989
990
991 #----------------------------------------------------------------------
992
993 if CONTRIBS_INC:
994 CONTRIBS_INC = [ CONTRIBS_INC ]
995 else:
996 CONTRIBS_INC = []
997
998
999 #----------------------------------------------------------------------
1000 # Define the GLCanvas extension module
1001 #----------------------------------------------------------------------
1002
1003 if BUILD_GLCANVAS:
1004 msg('Preparing GLCANVAS...')
1005 location = 'contrib/glcanvas'
1006
1007 swig_sources = run_swig(['glcanvas.i'], location, GENDIR, PKGDIR,
1008 USE_SWIG, swig_force, swig_args, swig_deps)
1009
1010 gl_libs = []
1011 if os.name == 'posix':
1012 gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
1013 gl_lflags = gl_config.split() + lflags
1014 gl_libs = libs
1015 else:
1016 gl_libs = libs + ['opengl32', 'glu32'] + makeLibName('gl')
1017 gl_lflags = lflags
1018
1019 ext = Extension('_glcanvas',
1020 swig_sources,
1021
1022 include_dirs = includes + CONTRIBS_INC,
1023 define_macros = defines,
1024
1025 library_dirs = libdirs,
1026 libraries = gl_libs,
1027
1028 extra_compile_args = cflags,
1029 extra_link_args = gl_lflags,
1030 )
1031
1032 wxpExtensions.append(ext)
1033
1034
1035 #----------------------------------------------------------------------
1036 # Define the OGL extension module
1037 #----------------------------------------------------------------------
1038
1039 if BUILD_OGL:
1040 msg('Preparing OGL...')
1041 location = 'contrib/ogl'
1042
1043 swig_sources = run_swig(['ogl.i'], location, GENDIR, PKGDIR,
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 ])
1051
1052 ext = Extension('_ogl',
1053 swig_sources,
1054
1055 include_dirs = includes + [ location ] + CONTRIBS_INC,
1056 define_macros = defines + [('wxUSE_DEPRECATED', '0')],
1057
1058 library_dirs = libdirs,
1059 libraries = libs + makeLibName('ogl'),
1060
1061 extra_compile_args = cflags,
1062 extra_link_args = lflags,
1063 )
1064
1065 wxpExtensions.append(ext)
1066
1067
1068
1069 #----------------------------------------------------------------------
1070 # Define the STC extension module
1071 #----------------------------------------------------------------------
1072
1073 if BUILD_STC:
1074 msg('Preparing STC...')
1075 location = 'contrib/stc'
1076 if os.name == 'nt':
1077 STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
1078 else:
1079 STC_H = opj(WXPREFIX, 'include/wx/stc')
1080
1081 ## NOTE: need to add something like this to the stc.bkl...
1082
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'))):
1087
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)
1095
1096
1097 swig_sources = run_swig(['stc.i'], location, '', PKGDIR,
1098 USE_SWIG, swig_force,
1099 swig_args + ['-I'+STC_H, '-I'+location],
1100 [opj(STC_H, 'stc.h')] + swig_deps)
1101
1102 ext = Extension('_stc',
1103 swig_sources,
1104
1105 include_dirs = includes + CONTRIBS_INC,
1106 define_macros = defines,
1107
1108 library_dirs = libdirs,
1109 libraries = libs + makeLibName('stc'),
1110
1111 extra_compile_args = cflags,
1112 extra_link_args = lflags,
1113 )
1114
1115 wxpExtensions.append(ext)
1116
1117
1118
1119 #----------------------------------------------------------------------
1120 # Define the IEWIN extension module (experimental)
1121 #----------------------------------------------------------------------
1122
1123 if BUILD_IEWIN:
1124 msg('Preparing IEWIN...')
1125 location = 'contrib/iewin'
1126
1127 swig_files = ['iewin.i', ]
1128
1129 swig_sources = run_swig(swig_files, location, '', PKGDIR,
1130 USE_SWIG, swig_force, swig_args, swig_deps)
1131
1132
1133 ext = Extension('_iewin', ['%s/IEHtmlWin.cpp' % location,
1134 '%s/wxactivex.cpp' % location,
1135 ] + swig_sources,
1136
1137 include_dirs = includes + CONTRIBS_INC,
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
1150 #----------------------------------------------------------------------
1151 # Define the XRC extension module
1152 #----------------------------------------------------------------------
1153
1154 if BUILD_XRC:
1155 msg('Preparing XRC...')
1156 location = 'contrib/xrc'
1157
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',
1169 swig_sources,
1170
1171 include_dirs = includes + CONTRIBS_INC,
1172 define_macros = defines,
1173
1174 library_dirs = libdirs,
1175 libraries = libs + makeLibName('xrc'),
1176
1177 extra_compile_args = cflags,
1178 extra_link_args = lflags,
1179 )
1180
1181 wxpExtensions.append(ext)
1182
1183
1184
1185 #----------------------------------------------------------------------
1186 # Define the GIZMOS extension module
1187 #----------------------------------------------------------------------
1188
1189 if BUILD_GIZMOS:
1190 msg('Preparing GIZMOS...')
1191 location = 'contrib/gizmos'
1192
1193 swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR,
1194 USE_SWIG, swig_force, swig_args, swig_deps)
1195
1196 ext = Extension('_gizmos',
1197 [ '%s/treelistctrl.cpp' % location ] + swig_sources,
1198
1199 include_dirs = includes + [ location ] + CONTRIBS_INC,
1200 define_macros = defines,
1201
1202 library_dirs = libdirs,
1203 libraries = libs + makeLibName('gizmos'),
1204
1205 extra_compile_args = cflags,
1206 extra_link_args = lflags,
1207 )
1208
1209 wxpExtensions.append(ext)
1210
1211
1212
1213 #----------------------------------------------------------------------
1214 # Define the DLLWIDGET extension module
1215 #----------------------------------------------------------------------
1216
1217 if BUILD_DLLWIDGET:
1218 msg('Preparing DLLWIDGET...')
1219 location = 'contrib/dllwidget'
1220 swig_files = ['dllwidget_.i']
1221
1222 swig_sources = run_swig(swig_files, location, '', PKGDIR,
1223 USE_SWIG, swig_force, swig_args, swig_deps)
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)
1227 CLEANUP.append(opj(PKGDIR, 'dllwidget.py'))
1228
1229 ext = Extension('dllwidget_c', [
1230 '%s/dllwidget.cpp' % location,
1231 ] + swig_sources,
1232
1233 include_dirs = includes + CONTRIBS_INC,
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
1246
1247
1248 #----------------------------------------------------------------------
1249 # Tools and scripts
1250 #----------------------------------------------------------------------
1251
1252 if NO_SCRIPTS:
1253 SCRIPTS = None
1254 else:
1255 SCRIPTS = [opj('scripts/helpviewer'),
1256 opj('scripts/img2png'),
1257 opj('scripts/img2xpm'),
1258 opj('scripts/img2py'),
1259 opj('scripts/xrced'),
1260 opj('scripts/pyshell'),
1261 opj('scripts/pycrust'),
1262 opj('scripts/pywrap'),
1263 opj('scripts/pywrap'),
1264 opj('scripts/pyalacarte'),
1265 opj('scripts/pyalamode'),
1266 ]
1267
1268
1269 DATA_FILES += find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
1270 DATA_FILES += find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
1271 DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html')
1272
1273
1274 #----------------------------------------------------------------------
1275 # Do the Setup/Build/Install/Whatever
1276 #----------------------------------------------------------------------
1277
1278 if __name__ == "__main__":
1279 if not PREP_ONLY:
1280 setup(name = 'wxPython',
1281 version = VERSION,
1282 description = DESCRIPTION,
1283 long_description = LONG_DESCRIPTION,
1284 author = AUTHOR,
1285 author_email = AUTHOR_EMAIL,
1286 url = URL,
1287 download_url = DOWNLOAD_URL,
1288 license = LICENSE,
1289 platforms = PLATFORMS,
1290 classifiers = filter(None, CLASSIFIERS.split("\n")),
1291 keywords = KEYWORDS,
1292
1293 packages = ['wxPython',
1294 'wxPython.lib',
1295 'wxPython.lib.colourchooser',
1296 'wxPython.lib.editor',
1297 'wxPython.lib.mixins',
1298 'wxPython.tools',
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',
1308 ],
1309
1310 ext_package = PKGDIR,
1311 ext_modules = wxpExtensions,
1312
1313 options = { 'build' : { 'build_base' : BUILD_BASE }},
1314
1315 scripts = SCRIPTS,
1316
1317 cmdclass = { 'install_data': smart_install_data,
1318 'clean': extra_clean,
1319 },
1320 data_files = DATA_FILES,
1321
1322 )
1323
1324
1325 #----------------------------------------------------------------------
1326 #----------------------------------------------------------------------