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 # This script imports it as just "config" because if wxPython doesn't
27 # exist yet, then it can't be imported from wx.build.config (since
28 # wx._core doesn't exist yet.) So instead we keep the main copy of
29 # config .py in the same place as setup.py, and then copy it to
30 # wx/build as needed below.
32 sys
.setup_is_main
= __name__
== "__main__" # an icky hack!
36 #----------------------------------------------------------------------
37 # Update the packaged config file.
38 #----------------------------------------------------------------------
40 copy_file('config.py', 'wx/build', update
=1, verbose
=1)
41 CLEANUP
.append('wx/build/config.py')
43 #----------------------------------------------------------------------
44 # Update the version file
45 #----------------------------------------------------------------------
47 # The version file is unconditionally updated every time setup.py is
48 # run since the version string can change based on the UNICODE flag
50 open('wx/__version__.py', 'w').write("""\
51 # This file was generated by setup.py...
53 VERSION_STRING = '%(VERSION)s'
54 MAJOR_VERSION = %(VER_MAJOR)s
55 MINOR_VERSION = %(VER_MINOR)s
56 RELEASE_VERSION = %(VER_RELEASE)s
57 SUBREL_VERSION = %(VER_SUBREL)s
59 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
60 SUBREL_VERSION, '%(VER_FLAGS)s')
62 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
65 CLEANUP
.append('wx/__version__.py')
68 #----------------------------------------------------------------------
69 # Define the CORE extension module
70 #----------------------------------------------------------------------
72 msg('Preparing CORE...')
73 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
74 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
81 'src/__core_rename.i',
82 'src/__core_reverse.txt',
101 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
102 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
105 # update the license files
107 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
108 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
109 CLEANUP
.append(opj('licence',file))
110 CLEANUP
.append('licence')
114 build_locale_dir(opj(PKGDIR
, 'locale'))
115 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
119 rc_file
= ['src/wxc.rc']
124 ext
= Extension('_core_', ['src/helpers.cpp',
126 ] + rc_file
+ swig_sources
,
128 include_dirs
= includes
,
129 define_macros
= defines
,
131 library_dirs
= libdirs
,
134 extra_compile_args
= cflags
,
135 extra_link_args
= lflags
,
139 wxpExtensions
.append(ext
)
145 # Extension for the GDI module
146 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
147 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
148 ['src/__gdi_rename.i',
167 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
168 include_dirs
= includes
,
169 define_macros
= defines
,
170 library_dirs
= libdirs
,
172 extra_compile_args
= cflags
,
173 extra_link_args
= lflags
,
176 wxpExtensions
.append(ext
)
183 # Extension for the windows module
184 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
185 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
186 ['src/__windows_rename.i',
187 'src/__windows_reverse.txt',
203 ext
= Extension('_windows_', swig_sources
,
204 include_dirs
= includes
,
205 define_macros
= defines
,
206 library_dirs
= libdirs
,
208 extra_compile_args
= cflags
,
209 extra_link_args
= lflags
,
212 wxpExtensions
.append(ext
)
217 # Extension for the controls module
218 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
219 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
220 [ 'src/__controls_rename.i',
221 'src/__controls_reverse.txt',
245 ext
= Extension('_controls_', swig_sources
,
246 include_dirs
= includes
,
247 define_macros
= defines
,
248 library_dirs
= libdirs
,
250 extra_compile_args
= cflags
,
251 extra_link_args
= lflags
,
254 wxpExtensions
.append(ext
)
259 # Extension for the misc module
260 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
261 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
262 [ 'src/__misc_rename.i',
263 'src/__misc_reverse.txt',
283 ext
= Extension('_misc_', swig_sources
,
284 include_dirs
= includes
,
285 define_macros
= defines
,
286 library_dirs
= libdirs
,
288 extra_compile_args
= cflags
,
289 extra_link_args
= lflags
,
292 wxpExtensions
.append(ext
)
297 ## Core modules that are not in the "core" namespace start here
300 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
301 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
302 ext
= Extension('_calendar', swig_sources
,
303 include_dirs
= includes
,
304 define_macros
= defines
,
305 library_dirs
= libdirs
,
307 extra_compile_args
= cflags
,
308 extra_link_args
= lflags
,
311 wxpExtensions
.append(ext
)
314 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
315 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
316 ext
= Extension('_grid', swig_sources
,
317 include_dirs
= includes
,
318 define_macros
= defines
,
319 library_dirs
= libdirs
,
321 extra_compile_args
= cflags
,
322 extra_link_args
= lflags
,
325 wxpExtensions
.append(ext
)
329 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
330 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
331 ext
= Extension('_html', swig_sources
,
332 include_dirs
= includes
,
333 define_macros
= defines
,
334 library_dirs
= libdirs
,
336 extra_compile_args
= cflags
,
337 extra_link_args
= lflags
,
340 wxpExtensions
.append(ext
)
344 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
345 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
346 ext
= Extension('_wizard', swig_sources
,
347 include_dirs
= includes
,
348 define_macros
= defines
,
349 library_dirs
= libdirs
,
351 extra_compile_args
= cflags
,
352 extra_link_args
= lflags
,
355 wxpExtensions
.append(ext
)
358 #----------------------------------------------------------------------
359 # Define the GLCanvas extension module
360 #----------------------------------------------------------------------
363 msg('Preparing GLCANVAS...')
364 location
= 'contrib/glcanvas'
366 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
367 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
370 if os
.name
== 'posix':
371 gl_config
= os
.popen(WX_CONFIG
+ ' --gl-libs', 'r').read()[:-1]
372 gl_lflags
= gl_config
.split() + lflags
375 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
378 ext
= Extension('_glcanvas',
381 include_dirs
= includes
+ CONTRIBS_INC
,
382 define_macros
= defines
,
384 library_dirs
= libdirs
,
387 extra_compile_args
= cflags
,
388 extra_link_args
= gl_lflags
,
391 wxpExtensions
.append(ext
)
394 #----------------------------------------------------------------------
395 # Define the OGL extension module
396 #----------------------------------------------------------------------
399 msg('Preparing OGL...')
400 location
= 'contrib/ogl'
402 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
403 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
404 [ '%s/_oglbasic.i' % location
,
405 '%s/_oglshapes.i' % location
,
406 '%s/_oglshapes2.i' % location
,
407 '%s/_oglcanvas.i' % location
,
408 '%s/_ogldefs.i' % location
,
411 ext
= Extension('_ogl',
414 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
415 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
417 library_dirs
= libdirs
,
418 libraries
= libs
+ makeLibName('ogl'),
420 extra_compile_args
= cflags
,
421 extra_link_args
= lflags
,
424 wxpExtensions
.append(ext
)
428 #----------------------------------------------------------------------
429 # Define the STC extension module
430 #----------------------------------------------------------------------
433 msg('Preparing STC...')
434 location
= 'contrib/stc'
436 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
438 STC_H
= opj(WXPREFIX
, 'include/wx/stc')
440 ## NOTE: need to add something like this to the stc.bkl...
442 ## # Check if gen_iface needs to be run for the wxSTC sources
443 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
444 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
445 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
447 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
449 ## os.chdir(opj(CTRB_SRC, 'stc'))
450 ## sys.path.insert(0, os.curdir)
452 ## gen_iface.main([])
456 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
457 USE_SWIG
, swig_force
,
458 swig_args
+ ['-I'+STC_H
, '-I'+location
],
459 [opj(STC_H
, 'stc.h')] + swig_deps
)
461 ext
= Extension('_stc',
464 include_dirs
= includes
+ CONTRIBS_INC
,
465 define_macros
= defines
,
467 library_dirs
= libdirs
,
468 libraries
= libs
+ makeLibName('stc'),
470 extra_compile_args
= cflags
,
471 extra_link_args
= lflags
,
474 wxpExtensions
.append(ext
)
478 #----------------------------------------------------------------------
479 # Define the IEWIN extension module (experimental)
480 #----------------------------------------------------------------------
483 msg('Preparing IEWIN...')
484 location
= 'contrib/iewin'
486 swig_files
= ['iewin.i', ]
488 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
489 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
492 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
493 '%s/wxactivex.cpp' % location
,
496 include_dirs
= includes
+ CONTRIBS_INC
,
497 define_macros
= defines
,
499 library_dirs
= libdirs
,
502 extra_compile_args
= cflags
,
503 extra_link_args
= lflags
,
506 wxpExtensions
.append(ext
)
509 #----------------------------------------------------------------------
510 # Define the ACTIVEX extension module (experimental)
511 #----------------------------------------------------------------------
514 msg('Preparing ACTIVEX...')
515 location
= 'contrib/activex'
516 axloc
= opj(location
, "wxie")
518 swig_files
= ['activex.i', ]
520 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
521 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
522 [ '%s/_activex_ex.py' % location
])
525 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
526 '%s/wxactivex.cpp' % axloc
,
529 include_dirs
= includes
+ [ axloc
],
530 define_macros
= defines
,
532 library_dirs
= libdirs
,
535 extra_compile_args
= cflags
,
536 extra_link_args
= lflags
,
539 wxpExtensions
.append(ext
)
542 #----------------------------------------------------------------------
543 # Define the XRC extension module
544 #----------------------------------------------------------------------
547 msg('Preparing XRC...')
548 location
= 'contrib/xrc'
550 swig_sources
= run_swig(['xrc.i'], location
, GENDIR
, PKGDIR
,
551 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
552 [ '%s/_xrc_rename.i' % location
,
553 '%s/_xrc_ex.py' % location
,
554 '%s/_xmlres.i' % location
,
555 '%s/_xmlsub.i' % location
,
556 '%s/_xml.i' % location
,
557 '%s/_xmlhandler.i' % location
,
560 ext
= Extension('_xrc',
563 include_dirs
= includes
+ CONTRIBS_INC
,
564 define_macros
= defines
,
566 library_dirs
= libdirs
,
567 libraries
= libs
+ makeLibName('xrc'),
569 extra_compile_args
= cflags
,
570 extra_link_args
= lflags
,
573 wxpExtensions
.append(ext
)
577 #----------------------------------------------------------------------
578 # Define the GIZMOS extension module
579 #----------------------------------------------------------------------
582 msg('Preparing GIZMOS...')
583 location
= 'contrib/gizmos'
585 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
586 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
588 ext
= Extension('_gizmos',
589 [ '%s/treelistctrl.cpp' % location
] + swig_sources
,
591 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
592 define_macros
= defines
,
594 library_dirs
= libdirs
,
595 libraries
= libs
+ makeLibName('gizmos'),
597 extra_compile_args
= cflags
,
598 extra_link_args
= lflags
,
601 wxpExtensions
.append(ext
)
605 #----------------------------------------------------------------------
606 # Define the DLLWIDGET extension module
607 #----------------------------------------------------------------------
610 msg('Preparing DLLWIDGET...')
611 location
= 'contrib/dllwidget'
612 swig_files
= ['dllwidget_.i']
614 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
615 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
617 # copy a contrib project specific py module to the main package dir
618 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
619 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
621 ext
= Extension('dllwidget_c', [
622 '%s/dllwidget.cpp' % location
,
625 include_dirs
= includes
+ CONTRIBS_INC
,
626 define_macros
= defines
,
628 library_dirs
= libdirs
,
631 extra_compile_args
= cflags
,
632 extra_link_args
= lflags
,
635 wxpExtensions
.append(ext
)
640 #----------------------------------------------------------------------
641 # Tools, scripts data files, etc.
642 #----------------------------------------------------------------------
647 SCRIPTS
= [opj('scripts/helpviewer'),
648 opj('scripts/img2png'),
649 opj('scripts/img2xpm'),
650 opj('scripts/img2py'),
651 opj('scripts/xrced'),
652 opj('scripts/pyshell'),
653 opj('scripts/pycrust'),
654 opj('scripts/pywrap'),
655 opj('scripts/pywrap'),
656 opj('scripts/pyalacarte'),
657 opj('scripts/pyalamode'),
661 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
662 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
663 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
669 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
670 i_files
= glob
.glob(opj("src/*.i")) + \
671 glob
.glob(opj("src/_*.py")) + \
672 glob
.glob(opj("src/*.swg"))
674 HEADERS
= zip(h_files
, ["/include/wx/wxPython"]*len(h_files
)) + \
675 zip(i_files
, ["/include/wx/wxPython/i_files"]*len(i_files
))
677 #----------------------------------------------------------------------
678 # Do the Setup/Build/Install/Whatever
679 #----------------------------------------------------------------------
681 if __name__
== "__main__":
683 setup(name
= 'wxPython',
685 description
= DESCRIPTION
,
686 long_description
= LONG_DESCRIPTION
,
688 author_email
= AUTHOR_EMAIL
,
690 download_url
= DOWNLOAD_URL
,
692 platforms
= PLATFORMS
,
693 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
696 packages
= ['wxPython',
698 'wxPython.lib.colourchooser',
699 'wxPython.lib.editor',
700 'wxPython.lib.mixins',
706 'wx.lib.colourchooser',
715 ext_package
= PKGDIR
,
716 ext_modules
= wxpExtensions
,
718 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
722 data_files
= DATA_FILES
,
725 cmdclass
= { 'install_data': wx_smart_install_data
,
726 'install_headers': wx_install_headers
,
727 'clean': wx_extra_clean
,
732 #----------------------------------------------------------------------
733 #----------------------------------------------------------------------