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