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 # patch distutils if it can't cope with the "classifiers" or
70 # "download_url" keywords
71 #----------------------------------------------------------------------
73 if sys
.version
< '2.2.3':
74 from distutils
.dist
import DistributionMetadata
75 DistributionMetadata
.classifiers
= None
76 DistributionMetadata
.download_url
= None
79 depends
= {'depends' : depends}
82 #----------------------------------------------------------------------
83 # Define the CORE extension module
84 #----------------------------------------------------------------------
86 msg('Preparing CORE...')
87 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
88 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
95 'src/__core_rename.i',
96 'src/__core_reverse.txt',
116 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
117 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
120 # update the license files
122 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
123 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
124 CLEANUP
.append(opj('licence',file))
125 CLEANUP
.append('licence')
129 build_locale_dir(opj(PKGDIR
, 'locale'))
130 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
134 rc_file
= ['src/wxc.rc']
139 ext
= Extension('_core_', ['src/helpers.cpp',
140 ] + rc_file
+ swig_sources
,
142 include_dirs
= includes
,
143 define_macros
= defines
,
145 library_dirs
= libdirs
,
148 extra_compile_args
= cflags
,
149 extra_link_args
= lflags
,
153 wxpExtensions
.append(ext
)
159 # Extension for the GDI module
160 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
161 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
162 ['src/__gdi_rename.i',
181 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
182 include_dirs
= includes
,
183 define_macros
= defines
,
184 library_dirs
= libdirs
,
186 extra_compile_args
= cflags
,
187 extra_link_args
= lflags
,
190 wxpExtensions
.append(ext
)
197 # Extension for the windows module
198 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
199 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
200 ['src/__windows_rename.i',
201 'src/__windows_reverse.txt',
217 ext
= Extension('_windows_', swig_sources
,
218 include_dirs
= includes
,
219 define_macros
= defines
,
220 library_dirs
= libdirs
,
222 extra_compile_args
= cflags
,
223 extra_link_args
= lflags
,
226 wxpExtensions
.append(ext
)
231 # Extension for the controls module
232 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
233 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
234 [ 'src/__controls_rename.i',
235 'src/__controls_reverse.txt',
259 ext
= Extension('_controls_', swig_sources
,
260 include_dirs
= includes
,
261 define_macros
= defines
,
262 library_dirs
= libdirs
,
264 extra_compile_args
= cflags
,
265 extra_link_args
= lflags
,
268 wxpExtensions
.append(ext
)
273 # Extension for the misc module
274 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
275 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
276 [ 'src/__misc_rename.i',
277 'src/__misc_reverse.txt',
298 ext
= Extension('_misc_', swig_sources
,
299 include_dirs
= includes
,
300 define_macros
= defines
,
301 library_dirs
= libdirs
,
303 extra_compile_args
= cflags
,
304 extra_link_args
= lflags
,
307 wxpExtensions
.append(ext
)
312 ## Core modules that are not in the "core" namespace start here
315 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
316 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
317 ext
= Extension('_calendar', swig_sources
,
318 include_dirs
= includes
,
319 define_macros
= defines
,
320 library_dirs
= libdirs
,
322 extra_compile_args
= cflags
,
323 extra_link_args
= lflags
,
326 wxpExtensions
.append(ext
)
329 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
330 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
331 ext
= Extension('_grid', 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(['html.i'], 'src', GENDIR
, PKGDIR
,
345 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
346 ext
= Extension('_html', 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
)
359 if not MONOLITHIC
and os
.name
== 'nt':
360 mediaLibs
.append(makeLibName('media')[0])
361 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
362 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
363 ext
= Extension('_media', swig_sources
,
364 include_dirs
= includes
,
365 define_macros
= defines
,
366 library_dirs
= libdirs
,
367 libraries
= mediaLibs
,
368 extra_compile_args
= cflags
,
369 extra_link_args
= lflags
,
372 wxpExtensions
.append(ext
)
375 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
376 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
377 ext
= Extension('_webkit', swig_sources
,
378 include_dirs
= includes
,
379 define_macros
= defines
,
380 library_dirs
= libdirs
,
382 extra_compile_args
= cflags
,
383 extra_link_args
= lflags
,
386 wxpExtensions
.append(ext
)
390 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
391 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
392 ext
= Extension('_wizard', swig_sources
,
393 include_dirs
= includes
,
394 define_macros
= defines
,
395 library_dirs
= libdirs
,
397 extra_compile_args
= cflags
,
398 extra_link_args
= lflags
,
401 wxpExtensions
.append(ext
)
405 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
406 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
407 [ 'src/_xrc_rename.i',
414 ext
= Extension('_xrc',
417 include_dirs
= includes
+ CONTRIBS_INC
,
418 define_macros
= defines
,
420 library_dirs
= libdirs
,
423 extra_compile_args
= cflags
,
424 extra_link_args
= lflags
,
426 wxpExtensions
.append(ext
)
429 #----------------------------------------------------------------------
430 # Define the GLCanvas extension module
431 #----------------------------------------------------------------------
434 msg('Preparing GLCANVAS...')
435 location
= 'contrib/glcanvas'
437 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
438 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
441 if os
.name
== 'posix':
442 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
443 gl_lflags
= gl_config
.split() + lflags
446 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
449 ext
= Extension('_glcanvas',
452 include_dirs
= includes
+ CONTRIBS_INC
,
453 define_macros
= defines
,
455 library_dirs
= libdirs
,
458 extra_compile_args
= cflags
,
459 extra_link_args
= gl_lflags
,
462 wxpExtensions
.append(ext
)
465 #----------------------------------------------------------------------
466 # Define the OGL extension module
467 #----------------------------------------------------------------------
470 msg('Preparing OGL...')
471 location
= 'contrib/ogl'
473 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
474 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
475 [ '%s/_oglbasic.i' % location
,
476 '%s/_oglshapes.i' % location
,
477 '%s/_oglshapes2.i' % location
,
478 '%s/_oglcanvas.i' % location
,
479 '%s/_ogldefs.i' % location
,
482 ext
= Extension('_ogl',
485 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
486 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
488 library_dirs
= libdirs
,
489 libraries
= libs
+ makeLibName('ogl'),
491 extra_compile_args
= cflags
,
492 extra_link_args
= lflags
,
495 wxpExtensions
.append(ext
)
499 #----------------------------------------------------------------------
500 # Define the STC extension module
501 #----------------------------------------------------------------------
504 msg('Preparing STC...')
505 location
= 'contrib/stc'
507 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
509 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
511 ## NOTE: need to add something like this to the stc.bkl...
513 ## # Check if gen_iface needs to be run for the wxSTC sources
514 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
515 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
516 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
518 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
520 ## os.chdir(opj(CTRB_SRC, 'stc'))
521 ## sys.path.insert(0, os.curdir)
523 ## gen_iface.main([])
527 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
528 USE_SWIG
, swig_force
,
529 swig_args
+ ['-I'+STC_H
, '-I'+location
],
530 [opj(STC_H
, 'stc.h')] + swig_deps
)
532 ext
= Extension('_stc',
535 include_dirs
= includes
+ CONTRIBS_INC
,
536 define_macros
= defines
,
538 library_dirs
= libdirs
,
539 libraries
= libs
+ makeLibName('stc'),
541 extra_compile_args
= cflags
,
542 extra_link_args
= lflags
,
545 wxpExtensions
.append(ext
)
549 #----------------------------------------------------------------------
550 # Define the IEWIN extension module (experimental)
551 #----------------------------------------------------------------------
554 msg('Preparing IEWIN...')
555 location
= 'contrib/iewin'
557 swig_files
= ['iewin.i', ]
559 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
560 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
563 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
564 '%s/wxactivex.cpp' % location
,
567 include_dirs
= includes
+ CONTRIBS_INC
,
568 define_macros
= defines
,
570 library_dirs
= libdirs
,
573 extra_compile_args
= cflags
,
574 extra_link_args
= lflags
,
577 wxpExtensions
.append(ext
)
580 #----------------------------------------------------------------------
581 # Define the ACTIVEX extension module (experimental)
582 #----------------------------------------------------------------------
585 msg('Preparing ACTIVEX...')
586 location
= 'contrib/activex'
587 axloc
= opj(location
, "wxie")
589 swig_files
= ['activex.i', ]
591 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
592 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
593 [ '%s/_activex_ex.py' % location
])
596 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
597 '%s/wxactivex.cpp' % axloc
,
600 include_dirs
= includes
+ [ axloc
],
601 define_macros
= defines
,
603 library_dirs
= libdirs
,
606 extra_compile_args
= cflags
,
607 extra_link_args
= lflags
,
610 wxpExtensions
.append(ext
)
613 #----------------------------------------------------------------------
614 # Define the GIZMOS extension module
615 #----------------------------------------------------------------------
618 msg('Preparing GIZMOS...')
619 location
= 'contrib/gizmos'
621 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
622 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
624 ext
= Extension('_gizmos',
625 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
627 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
628 define_macros
= defines
,
630 library_dirs
= libdirs
,
631 libraries
= libs
+ makeLibName('gizmos'),
633 extra_compile_args
= cflags
,
634 extra_link_args
= lflags
,
637 wxpExtensions
.append(ext
)
641 #----------------------------------------------------------------------
642 # Define the DLLWIDGET extension module
643 #----------------------------------------------------------------------
646 msg('Preparing DLLWIDGET...')
647 location
= 'contrib/dllwidget'
648 swig_files
= ['dllwidget_.i']
650 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
651 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
653 # copy a contrib project specific py module to the main package dir
654 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
655 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
657 ext
= Extension('dllwidget_c', [
658 '%s/dllwidget.cpp' % location
,
661 include_dirs
= includes
+ CONTRIBS_INC
,
662 define_macros
= defines
,
664 library_dirs
= libdirs
,
667 extra_compile_args
= cflags
,
668 extra_link_args
= lflags
,
671 wxpExtensions
.append(ext
)
676 #----------------------------------------------------------------------
677 # Tools, scripts data files, etc.
678 #----------------------------------------------------------------------
683 SCRIPTS
= [opj('scripts/helpviewer'),
684 opj('scripts/img2png'),
685 opj('scripts/img2py'),
686 opj('scripts/img2xpm'),
687 opj('scripts/pyalacarte'),
688 opj('scripts/pyalamode'),
689 opj('scripts/pycrust'),
690 opj('scripts/pyshell'),
691 opj('scripts/pywrap'),
692 opj('scripts/pywrap'),
693 opj('scripts/pywxrc'),
694 opj('scripts/xrced'),
699 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
700 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
701 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
707 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
708 i_files
= glob
.glob(opj("src/*.i")) + \
709 glob
.glob(opj("src/_*.py")) + \
710 glob
.glob(opj("src/*.swg"))
712 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
713 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
717 if INSTALL_MULTIVERSION
:
718 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
)
719 open("src/wx.pth", "w").write(EXTRA_PATH
)
720 CLEANUP
.append("src/wx.pth")
726 #----------------------------------------------------------------------
727 # Do the Setup/Build/Install/Whatever
728 #----------------------------------------------------------------------
730 if __name__
== "__main__":
733 setup(name
= 'wxPython',
735 description
= DESCRIPTION
,
736 long_description
= LONG_DESCRIPTION
,
738 author_email
= AUTHOR_EMAIL
,
740 download_url
= DOWNLOAD_URL
,
742 platforms
= PLATFORMS
,
743 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
746 packages
= ['wxPython',
748 'wxPython.lib.colourchooser',
749 'wxPython.lib.editor',
750 'wxPython.lib.mixins',
756 'wx.lib.colourchooser',
758 'wx.lib.floatcanvas',
767 extra_path
= EXTRA_PATH
,
769 ext_package
= PKGDIR
,
770 ext_modules
= wxpExtensions
,
772 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
776 data_files
= DATA_FILES
,
779 # Override some of the default distutils command classes with my own
780 cmdclass
= { 'install' : wx_install
,
781 'install_data': wx_smart_install_data
,
782 'install_headers': wx_install_headers
,
783 'clean': wx_extra_clean
,
788 if INSTALL_MULTIVERSION
:
789 setup(name
= 'wxPython-common',
791 description
= DESCRIPTION
,
792 long_description
= LONG_DESCRIPTION
,
794 author_email
= AUTHOR_EMAIL
,
796 download_url
= DOWNLOAD_URL
,
798 platforms
= PLATFORMS
,
799 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
802 package_dir
= { '': 'wxversion' }
,
803 py_modules
= ['wxversion'],
805 data_files
= [('', ['src/wx.pth'])],
807 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
810 cmdclass
= { 'install_data': wx_smart_install_data
,
814 #----------------------------------------------------------------------
815 #----------------------------------------------------------------------