2 #----------------------------------------------------------------------
4 # Purpose: Distutils script for building wxPython
10 # Copyright: (c) 2000 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------
17 # The full contents of the wx.build.config module used to be located
18 # here in setup.py. They were split into a separate module so it will
19 # be installed with wxPython and can then be used by the build scripts
20 # of other extension modules that wich to be wxPython compatible. The
21 # split is still fairly new and hasn't been tested by building
22 # third-party extensions yet, so expect some things to still shift
23 # back and forth, and also more stuff in config.py will get converted
26 sys
.setup_is_main
= __name__
== "__main__" # an icky hack!
27 from wx
.build
.config
import *
30 #----------------------------------------------------------------------
31 # Update the version file
32 #----------------------------------------------------------------------
34 # The version file is unconditionally updated every time setup.py is
35 # run since the version string can change based on the UNICODE flag
37 open('wx/__version__.py', 'w').write("""\
38 # This file was generated by setup.py...
40 VERSION_STRING = '%(VERSION)s'
41 MAJOR_VERSION = %(VER_MAJOR)s
42 MINOR_VERSION = %(VER_MINOR)s
43 RELEASE_VERSION = %(VER_RELEASE)s
44 SUBREL_VERSION = %(VER_SUBREL)s
46 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
47 SUBREL_VERSION, '%(VER_FLAGS)s')
49 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
52 CLEANUP
.append('wx/__version__.py')
55 #----------------------------------------------------------------------
56 # Define the CORE extension module
57 #----------------------------------------------------------------------
59 msg('Preparing CORE...')
60 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
61 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
69 'src/_core_reverse.txt',
87 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
88 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
91 # update the license files
93 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
94 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
95 CLEANUP
.append(opj('licence',file))
96 CLEANUP
.append('licence')
100 build_locale_dir(opj(PKGDIR
, 'locale'))
101 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
105 rc_file
= ['src/wxc.rc']
110 ext
= Extension('_core', ['src/helpers.cpp',
112 ] + rc_file
+ swig_sources
,
114 include_dirs
= includes
,
115 define_macros
= defines
,
117 library_dirs
= libdirs
,
120 extra_compile_args
= cflags
,
121 extra_link_args
= lflags
,
125 wxpExtensions
.append(ext
)
131 # Extension for the GDI module
132 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
133 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
134 ['src/_gdi_rename.i',
152 ext
= Extension('_gdi', ['src/drawlist.cpp'] + swig_sources
,
153 include_dirs
= includes
,
154 define_macros
= defines
,
155 library_dirs
= libdirs
,
157 extra_compile_args
= cflags
,
158 extra_link_args
= lflags
,
161 wxpExtensions
.append(ext
)
168 # Extension for the windows module
169 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
170 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
171 ['src/_windows_rename.i',
172 'src/_windows_reverse.txt',
187 ext
= Extension('_windows', swig_sources
,
188 include_dirs
= includes
,
189 define_macros
= defines
,
190 library_dirs
= libdirs
,
192 extra_compile_args
= cflags
,
193 extra_link_args
= lflags
,
196 wxpExtensions
.append(ext
)
201 # Extension for the controls module
202 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
203 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
204 [ 'src/_controls_rename.i',
205 'src/_controls_reverse.txt',
228 ext
= Extension('_controls', swig_sources
,
229 include_dirs
= includes
,
230 define_macros
= defines
,
231 library_dirs
= libdirs
,
233 extra_compile_args
= cflags
,
234 extra_link_args
= lflags
,
237 wxpExtensions
.append(ext
)
242 # Extension for the misc module
243 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
244 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
263 ext
= Extension('_misc', swig_sources
,
264 include_dirs
= includes
,
265 define_macros
= defines
,
266 library_dirs
= libdirs
,
268 extra_compile_args
= cflags
,
269 extra_link_args
= lflags
,
272 wxpExtensions
.append(ext
)
277 ## Core modules that are not in the "core" namespace start here
280 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
281 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
282 ext
= Extension('_calendar', swig_sources
,
283 include_dirs
= includes
,
284 define_macros
= defines
,
285 library_dirs
= libdirs
,
287 extra_compile_args
= cflags
,
288 extra_link_args
= lflags
,
291 wxpExtensions
.append(ext
)
294 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
295 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
296 ext
= Extension('_grid', swig_sources
,
297 include_dirs
= includes
,
298 define_macros
= defines
,
299 library_dirs
= libdirs
,
301 extra_compile_args
= cflags
,
302 extra_link_args
= lflags
,
305 wxpExtensions
.append(ext
)
309 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
310 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
311 ext
= Extension('_html', swig_sources
,
312 include_dirs
= includes
,
313 define_macros
= defines
,
314 library_dirs
= libdirs
,
316 extra_compile_args
= cflags
,
317 extra_link_args
= lflags
,
320 wxpExtensions
.append(ext
)
324 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
325 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
326 ext
= Extension('_wizard', swig_sources
,
327 include_dirs
= includes
,
328 define_macros
= defines
,
329 library_dirs
= libdirs
,
331 extra_compile_args
= cflags
,
332 extra_link_args
= lflags
,
335 wxpExtensions
.append(ext
)
338 #----------------------------------------------------------------------
339 # Define the GLCanvas extension module
340 #----------------------------------------------------------------------
343 msg('Preparing GLCANVAS...')
344 location
= 'contrib/glcanvas'
346 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
347 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
350 if os
.name
== 'posix':
351 gl_config
= os
.popen(WX_CONFIG
+ ' --gl-libs', 'r').read()[:-1]
352 gl_lflags
= gl_config
.split() + lflags
355 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
358 ext
= Extension('_glcanvas',
361 include_dirs
= includes
+ CONTRIBS_INC
,
362 define_macros
= defines
,
364 library_dirs
= libdirs
,
367 extra_compile_args
= cflags
,
368 extra_link_args
= gl_lflags
,
371 wxpExtensions
.append(ext
)
374 #----------------------------------------------------------------------
375 # Define the OGL extension module
376 #----------------------------------------------------------------------
379 msg('Preparing OGL...')
380 location
= 'contrib/ogl'
382 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
383 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
384 [ '%s/_oglbasic.i' % location
,
385 '%s/_oglshapes.i' % location
,
386 '%s/_oglshapes2.i' % location
,
387 '%s/_oglcanvas.i' % location
,
388 '%s/_ogldefs.i' % location
,
391 ext
= Extension('_ogl',
394 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
395 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
397 library_dirs
= libdirs
,
398 libraries
= libs
+ makeLibName('ogl'),
400 extra_compile_args
= cflags
,
401 extra_link_args
= lflags
,
404 wxpExtensions
.append(ext
)
408 #----------------------------------------------------------------------
409 # Define the STC extension module
410 #----------------------------------------------------------------------
413 msg('Preparing STC...')
414 location
= 'contrib/stc'
416 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
418 STC_H
= opj(WXPREFIX
, 'include/wx/stc')
420 ## NOTE: need to add something like this to the stc.bkl...
422 ## # Check if gen_iface needs to be run for the wxSTC sources
423 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
424 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
425 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
427 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
429 ## os.chdir(opj(CTRB_SRC, 'stc'))
430 ## sys.path.insert(0, os.curdir)
432 ## gen_iface.main([])
436 swig_sources
= run_swig(['stc.i'], location
, '', PKGDIR
,
437 USE_SWIG
, swig_force
,
438 swig_args
+ ['-I'+STC_H
, '-I'+location
],
439 [opj(STC_H
, 'stc.h')] + swig_deps
)
441 ext
= Extension('_stc',
444 include_dirs
= includes
+ CONTRIBS_INC
,
445 define_macros
= defines
,
447 library_dirs
= libdirs
,
448 libraries
= libs
+ makeLibName('stc'),
450 extra_compile_args
= cflags
,
451 extra_link_args
= lflags
,
454 wxpExtensions
.append(ext
)
458 #----------------------------------------------------------------------
459 # Define the IEWIN extension module (experimental)
460 #----------------------------------------------------------------------
463 msg('Preparing IEWIN...')
464 location
= 'contrib/iewin'
466 swig_files
= ['iewin.i', ]
468 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
469 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
472 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
473 '%s/wxactivex.cpp' % location
,
476 include_dirs
= includes
+ CONTRIBS_INC
,
477 define_macros
= defines
,
479 library_dirs
= libdirs
,
482 extra_compile_args
= cflags
,
483 extra_link_args
= lflags
,
486 wxpExtensions
.append(ext
)
489 #----------------------------------------------------------------------
490 # Define the ACTIVEX extension module (experimental)
491 #----------------------------------------------------------------------
494 msg('Preparing ACTIVEX...')
495 location
= 'contrib/activex'
496 axloc
= opj(location
, "wxie")
498 swig_files
= ['activex.i', ]
500 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
501 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
502 [ '%s/_activex_ex.py' % location
])
505 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
506 '%s/wxactivex.cpp' % axloc
,
509 include_dirs
= includes
+ [ axloc
],
510 define_macros
= defines
,
512 library_dirs
= libdirs
,
515 extra_compile_args
= cflags
,
516 extra_link_args
= lflags
,
519 wxpExtensions
.append(ext
)
522 #----------------------------------------------------------------------
523 # Define the XRC extension module
524 #----------------------------------------------------------------------
527 msg('Preparing XRC...')
528 location
= 'contrib/xrc'
530 swig_sources
= run_swig(['xrc.i'], location
, '', PKGDIR
,
531 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
532 [ '%s/_xrc_rename.i' % location
,
533 '%s/_xrc_ex.py' % location
,
534 '%s/_xmlres.i' % location
,
535 '%s/_xmlsub.i' % location
,
536 '%s/_xml.i' % location
,
537 '%s/_xmlhandler.i' % location
,
540 ext
= Extension('_xrc',
543 include_dirs
= includes
+ CONTRIBS_INC
,
544 define_macros
= defines
,
546 library_dirs
= libdirs
,
547 libraries
= libs
+ makeLibName('xrc'),
549 extra_compile_args
= cflags
,
550 extra_link_args
= lflags
,
553 wxpExtensions
.append(ext
)
557 #----------------------------------------------------------------------
558 # Define the GIZMOS extension module
559 #----------------------------------------------------------------------
562 msg('Preparing GIZMOS...')
563 location
= 'contrib/gizmos'
565 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
566 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
568 ext
= Extension('_gizmos',
569 [ '%s/treelistctrl.cpp' % location
] + swig_sources
,
571 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
572 define_macros
= defines
,
574 library_dirs
= libdirs
,
575 libraries
= libs
+ makeLibName('gizmos'),
577 extra_compile_args
= cflags
,
578 extra_link_args
= lflags
,
581 wxpExtensions
.append(ext
)
585 #----------------------------------------------------------------------
586 # Define the DLLWIDGET extension module
587 #----------------------------------------------------------------------
590 msg('Preparing DLLWIDGET...')
591 location
= 'contrib/dllwidget'
592 swig_files
= ['dllwidget_.i']
594 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
595 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
597 # copy a contrib project specific py module to the main package dir
598 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
599 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
601 ext
= Extension('dllwidget_c', [
602 '%s/dllwidget.cpp' % location
,
605 include_dirs
= includes
+ CONTRIBS_INC
,
606 define_macros
= defines
,
608 library_dirs
= libdirs
,
611 extra_compile_args
= cflags
,
612 extra_link_args
= lflags
,
615 wxpExtensions
.append(ext
)
620 #----------------------------------------------------------------------
621 # Tools, scripts data files, etc.
622 #----------------------------------------------------------------------
627 SCRIPTS
= [opj('scripts/helpviewer'),
628 opj('scripts/img2png'),
629 opj('scripts/img2xpm'),
630 opj('scripts/img2py'),
631 opj('scripts/xrced'),
632 opj('scripts/pyshell'),
633 opj('scripts/pycrust'),
634 opj('scripts/pywrap'),
635 opj('scripts/pywrap'),
636 opj('scripts/pyalacarte'),
637 opj('scripts/pyalamode'),
641 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
642 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
643 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
649 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
650 i_files
= glob
.glob(opj("src/*.i")) + \
651 glob
.glob(opj("src/_*.py")) + \
652 glob
.glob(opj("src/*.swg"))
654 HEADERS
= zip(h_files
, ["/include/wx/wxPython"]*len(h_files
)) + \
655 zip(i_files
, ["/include/wx/wxPython/i_files"]*len(i_files
))
657 #----------------------------------------------------------------------
658 # Do the Setup/Build/Install/Whatever
659 #----------------------------------------------------------------------
661 if __name__
== "__main__":
663 setup(name
= 'wxPython',
665 description
= DESCRIPTION
,
666 long_description
= LONG_DESCRIPTION
,
668 author_email
= AUTHOR_EMAIL
,
670 download_url
= DOWNLOAD_URL
,
672 platforms
= PLATFORMS
,
673 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
676 packages
= ['wxPython',
678 'wxPython.lib.colourchooser',
679 'wxPython.lib.editor',
680 'wxPython.lib.mixins',
686 'wx.lib.colourchooser',
694 ext_package
= PKGDIR
,
695 ext_modules
= wxpExtensions
,
697 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
701 data_files
= DATA_FILES
,
704 cmdclass
= { 'install_data': wx_smart_install_data
,
705 'install_headers': wx_install_headers
,
706 'clean': wx_extra_clean
,
711 #----------------------------------------------------------------------
712 #----------------------------------------------------------------------