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 wish to be wxPython compatible.
21 # The 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 # To fully support external builds, we need to have a build options
33 # file that is created whenever a new wxPython build is performed.
34 # We happen to be doing that here in this script, so make sure to
35 # remove the build_options.py file, so that config.py will recreate it.
37 for bo_name
in ["build_options.py", "build_options.pyc"]:
38 if os
.path
.exists(bo_name
):
41 sys
.setup_is_main
= __name__
== "__main__" # an icky hack!
45 #----------------------------------------------------------------------
46 # Update the packaged config file.
47 #----------------------------------------------------------------------
49 copy_file('config.py', 'wx/build', update
=1, verbose
=1)
50 copy_file('build_options.py', 'wx/build', update
=1, verbose
=1)
51 CLEANUP
.append('wx/build/config.py')
52 CLEANUP
.append('wx/build/build_options.py')
54 #----------------------------------------------------------------------
55 # Update the version file
56 #----------------------------------------------------------------------
58 # The version file is unconditionally updated every time setup.py is
59 # run since the version string can change based on the UNICODE flag
61 open('wx/__version__.py', 'w').write("""\
62 # This file was generated by setup.py...
64 VERSION_STRING = '%(VERSION)s'
65 MAJOR_VERSION = %(VER_MAJOR)s
66 MINOR_VERSION = %(VER_MINOR)s
67 RELEASE_VERSION = %(VER_RELEASE)s
68 SUBREL_VERSION = %(VER_SUBREL)s
70 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
71 SUBREL_VERSION, '%(VER_FLAGS)s')
73 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
76 CLEANUP
.append('wx/__version__.py')
79 #----------------------------------------------------------------------
80 # Write the SWIG version to a header file
81 #----------------------------------------------------------------------
86 open('include/wx/wxPython/swigver.h', 'w').write('''\
87 // This file was generated by setup.py
89 #define wxPy_SWIG_VERSION "SWIG-%s"
91 msg('Using SWIG-' + SVER
)
93 msg('\nUnable to get SWIG version number\n')
97 #----------------------------------------------------------------------
98 # patch distutils if it can't cope with the "classifiers" or
99 # "download_url" keywords
100 #----------------------------------------------------------------------
102 if sys
.version
< '2.2.3':
103 from distutils
.dist
import DistributionMetadata
104 DistributionMetadata
.classifiers
= None
105 DistributionMetadata
.download_url
= None
108 depends
= {'depends' : depends}
111 #----------------------------------------------------------------------
112 # Define the CORE extension module
113 #----------------------------------------------------------------------
115 msg('Preparing CORE...')
116 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
117 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
121 'src/_constraints.i',
124 'src/__core_rename.i',
125 'src/__core_reverse.txt',
146 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
147 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
150 # update the license files
152 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
153 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
154 CLEANUP
.append(opj('licence',file))
155 CLEANUP
.append('licence')
159 build_locale_dir(opj(PKGDIR
, 'locale'))
160 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
164 rc_file
= ['src/wxc.rc']
169 ext
= Extension('_core_', ['src/helpers.cpp',
170 ] + rc_file
+ swig_sources
,
172 include_dirs
= includes
,
173 define_macros
= defines
,
175 library_dirs
= libdirs
,
178 extra_compile_args
= cflags
,
179 extra_link_args
= lflags
,
183 wxpExtensions
.append(ext
)
189 # Extension for the GDI module
190 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
191 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
192 ['src/__gdi_rename.i',
214 ext
= Extension('_gdi_', ['src/drawlist.cpp',
217 include_dirs
= includes
,
218 define_macros
= defines
,
219 library_dirs
= libdirs
,
221 extra_compile_args
= cflags
,
222 extra_link_args
= lflags
,
225 wxpExtensions
.append(ext
)
232 # Extension for the windows module
233 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
234 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
235 ['src/__windows_rename.i',
236 'src/__windows_reverse.txt',
252 ext
= Extension('_windows_', swig_sources
,
253 include_dirs
= includes
,
254 define_macros
= defines
,
255 library_dirs
= libdirs
,
257 extra_compile_args
= cflags
,
258 extra_link_args
= lflags
,
261 wxpExtensions
.append(ext
)
266 # Extension for the controls module
267 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
268 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
269 [ 'src/__controls_rename.i',
270 'src/__controls_reverse.txt',
297 ext
= Extension('_controls_', swig_sources
,
298 include_dirs
= includes
,
299 define_macros
= defines
,
300 library_dirs
= libdirs
,
302 extra_compile_args
= cflags
,
303 extra_link_args
= lflags
,
306 wxpExtensions
.append(ext
)
311 # Extension for the misc module
312 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
313 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
314 [ 'src/__misc_rename.i',
315 'src/__misc_reverse.txt',
337 ext
= Extension('_misc_', swig_sources
,
338 include_dirs
= includes
,
339 define_macros
= defines
,
340 library_dirs
= libdirs
,
342 extra_compile_args
= cflags
,
343 extra_link_args
= lflags
,
346 wxpExtensions
.append(ext
)
351 ## Core modules that are not in the "core" namespace start here
354 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
355 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
356 ext
= Extension('_calendar', swig_sources
,
357 include_dirs
= includes
,
358 define_macros
= defines
,
359 library_dirs
= libdirs
,
361 extra_compile_args
= cflags
,
362 extra_link_args
= lflags
,
365 wxpExtensions
.append(ext
)
368 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
369 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
370 ext
= Extension('_grid', swig_sources
,
371 include_dirs
= includes
,
372 define_macros
= defines
,
373 library_dirs
= libdirs
,
375 extra_compile_args
= cflags
,
376 extra_link_args
= lflags
,
379 wxpExtensions
.append(ext
)
383 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
384 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
385 ext
= Extension('_html', swig_sources
,
386 include_dirs
= includes
,
387 define_macros
= defines
,
388 library_dirs
= libdirs
,
390 extra_compile_args
= cflags
,
391 extra_link_args
= lflags
,
394 wxpExtensions
.append(ext
)
399 mediaLibs
+= makeLibName('media')
400 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
401 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
402 ext
= Extension('_media', swig_sources
,
403 include_dirs
= includes
,
404 define_macros
= defines
,
405 library_dirs
= libdirs
,
406 libraries
= mediaLibs
,
407 extra_compile_args
= cflags
,
408 extra_link_args
= lflags
,
411 wxpExtensions
.append(ext
)
414 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
415 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
416 ext
= Extension('_webkit', swig_sources
,
417 include_dirs
= includes
,
418 define_macros
= defines
,
419 library_dirs
= libdirs
,
421 extra_compile_args
= cflags
,
422 extra_link_args
= lflags
,
425 wxpExtensions
.append(ext
)
429 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
430 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
431 ext
= Extension('_wizard', swig_sources
,
432 include_dirs
= includes
,
433 define_macros
= defines
,
434 library_dirs
= libdirs
,
436 extra_compile_args
= cflags
,
437 extra_link_args
= lflags
,
440 wxpExtensions
.append(ext
)
444 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
445 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
446 [ 'src/_xrc_rename.i',
454 xrcLib
= makeLibName('xrc')
457 ext
= Extension('_xrc',
460 include_dirs
= includes
+ CONTRIBS_INC
,
461 define_macros
= defines
,
463 library_dirs
= libdirs
,
464 libraries
= libs
+ xrcLib
,
466 extra_compile_args
= cflags
,
467 extra_link_args
= lflags
,
469 wxpExtensions
.append(ext
)
473 swig_sources
= run_swig(['richtext.i'], 'src', GENDIR
, PKGDIR
,
474 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
476 richLib
= makeLibName('richtext')
479 ext
= Extension('_richtext', swig_sources
,
480 include_dirs
= includes
,
481 define_macros
= defines
,
482 library_dirs
= libdirs
,
483 libraries
= libs
+ richLib
,
484 extra_compile_args
= cflags
,
485 extra_link_args
= lflags
,
488 wxpExtensions
.append(ext
)
492 swig_sources
= run_swig(['aui.i'], 'src', GENDIR
, PKGDIR
,
493 USE_SWIG
, swig_force
,
494 swig_args
+ ['-I'+opj(WXDIR
, 'include/wx/aui')],
495 swig_deps
+ ['src/_aui_docstrings.i',
496 opj(WXDIR
, 'include/wx/aui/framemanager.h'),
497 opj(WXDIR
, 'include/wx/aui/floatpane.h'),
498 opj(WXDIR
, 'include/wx/aui/dockart.h'),
499 opj(WXDIR
, 'include/wx/aui/auibook.h'),
502 auiLib
= makeLibName('aui')
505 ext
= Extension('_aui', swig_sources
,
506 include_dirs
= includes
,
507 define_macros
= defines
,
508 library_dirs
= libdirs
,
509 libraries
= libs
+ auiLib
,
510 extra_compile_args
= cflags
,
511 extra_link_args
= lflags
,
514 wxpExtensions
.append(ext
)
520 #----------------------------------------------------------------------
521 # Define the GLCanvas extension module
522 #----------------------------------------------------------------------
525 msg('Preparing GLCANVAS...')
526 location
= 'contrib/glcanvas'
528 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
529 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
532 gl_libdirs
= libdirs
[:]
533 if os
.name
== 'posix':
534 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
535 gl_lflags
= gl_config
.split()
536 gl_lflags
= adjustLFLAGS(gl_lflags
, gl_libdirs
, gl_libs
)
540 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
543 ext
= Extension('_glcanvas',
546 include_dirs
= includes
+ CONTRIBS_INC
,
547 define_macros
= defines
,
549 library_dirs
= gl_libdirs
,
552 extra_compile_args
= cflags
,
553 extra_link_args
= gl_lflags
,
556 wxpExtensions
.append(ext
)
559 #----------------------------------------------------------------------
560 # Define the OGL extension module
561 #----------------------------------------------------------------------
564 msg('Preparing OGL...')
565 location
= 'contrib/ogl'
567 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
568 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
569 [ '%s/_oglbasic.i' % location
,
570 '%s/_oglshapes.i' % location
,
571 '%s/_oglshapes2.i' % location
,
572 '%s/_oglcanvas.i' % location
,
573 '%s/_ogldefs.i' % location
,
576 ext
= Extension('_ogl',
579 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
580 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
582 library_dirs
= libdirs
,
583 libraries
= libs
+ makeLibName('ogl'),
585 extra_compile_args
= cflags
,
586 extra_link_args
= lflags
,
589 wxpExtensions
.append(ext
)
593 #----------------------------------------------------------------------
594 # Define the STC extension module
595 #----------------------------------------------------------------------
598 msg('Preparing STC...')
599 location
= 'contrib/stc'
601 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
603 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
605 ## NOTE: need to add something like this to the stc.bkl...
607 ## # Check if gen_iface needs to be run for the wxSTC sources
608 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
609 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
610 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
612 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
614 ## os.chdir(opj(CTRB_SRC, 'stc'))
615 ## sys.path.insert(0, os.curdir)
617 ## gen_iface.main([])
621 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
622 USE_SWIG
, swig_force
,
623 swig_args
+ ['-I'+STC_H
, '-I'+location
],
624 [opj(STC_H
, 'stc.h'),
625 opj(location
, "_stc_utf8_methods.py"),
626 opj(location
, "_stc_docstrings.i"),
627 opj(location
, "_stc_gendocs.i"),
630 ext
= Extension('_stc',
633 include_dirs
= includes
+ CONTRIBS_INC
,
634 define_macros
= defines
,
636 library_dirs
= libdirs
,
637 libraries
= libs
+ makeLibName('stc'),
639 extra_compile_args
= cflags
,
640 extra_link_args
= lflags
,
643 wxpExtensions
.append(ext
)
646 #----------------------------------------------------------------------
647 # Define the ACTIVEX extension module (experimental)
648 #----------------------------------------------------------------------
651 msg('Preparing ACTIVEX...')
652 location
= 'contrib/activex'
653 axloc
= opj(location
, "wxie")
655 swig_files
= ['activex.i', ]
657 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
658 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
659 [ '%s/_activex_ex.py' % location
])
662 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
663 '%s/wxactivex.cpp' % axloc
,
666 include_dirs
= includes
+ [ axloc
],
667 define_macros
= defines
,
669 library_dirs
= libdirs
,
672 extra_compile_args
= cflags
,
673 extra_link_args
= lflags
,
676 wxpExtensions
.append(ext
)
679 #----------------------------------------------------------------------
680 # Define the GIZMOS extension module
681 #----------------------------------------------------------------------
684 msg('Preparing GIZMOS...')
685 location
= 'contrib/gizmos'
687 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
688 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
689 [ '%s/_treelist.i' % location
])
691 ext
= Extension('_gizmos',
692 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
694 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
695 define_macros
= defines
,
697 library_dirs
= libdirs
,
698 libraries
= libs
+ makeLibName('gizmos'),
700 extra_compile_args
= cflags
,
701 extra_link_args
= lflags
,
704 wxpExtensions
.append(ext
)
707 #----------------------------------------------------------------------
708 # Define the ANIMATE extension module
709 #----------------------------------------------------------------------
712 msg('Preparing ANIMATE...')
713 location
= 'contrib/animate'
715 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
716 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
718 ext
= Extension('_animate',
721 include_dirs
= includes
+ CONTRIBS_INC
,
722 define_macros
= defines
,
724 library_dirs
= libdirs
,
725 libraries
= libs
+ makeLibName('animate'),
727 extra_compile_args
= cflags
,
728 extra_link_args
= lflags
,
731 wxpExtensions
.append(ext
)
735 #----------------------------------------------------------------------
736 # Define the DLLWIDGET extension module
737 #----------------------------------------------------------------------
740 msg('Preparing DLLWIDGET...')
741 location
= 'contrib/dllwidget'
742 swig_files
= ['dllwidget_.i']
744 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
745 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
747 # copy a contrib project specific py module to the main package dir
748 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
749 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
751 ext
= Extension('dllwidget_c', [
752 '%s/dllwidget.cpp' % location
,
755 include_dirs
= includes
+ CONTRIBS_INC
,
756 define_macros
= defines
,
758 library_dirs
= libdirs
,
761 extra_compile_args
= cflags
,
762 extra_link_args
= lflags
,
765 wxpExtensions
.append(ext
)
770 #----------------------------------------------------------------------
771 # Tools, scripts data files, etc.
772 #----------------------------------------------------------------------
777 SCRIPTS
= [opj('scripts/helpviewer'),
778 opj('scripts/img2png'),
779 opj('scripts/img2py'),
780 opj('scripts/img2xpm'),
781 opj('scripts/pyalacarte'),
782 opj('scripts/pyalamode'),
783 opj('scripts/pycrust'),
784 opj('scripts/pyshell'),
785 opj('scripts/pywrap'),
786 opj('scripts/pywrap'),
787 opj('scripts/pywxrc'),
788 opj('scripts/xrced'),
793 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
794 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
795 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
801 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
802 i_files
= glob
.glob(opj("src/*.i")) + \
803 glob
.glob(opj("src/_*.py")) + \
804 glob
.glob(opj("src/*.swg"))
806 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
807 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
811 if INSTALL_MULTIVERSION
:
812 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
813 open("src/wx.pth", "w").write(EXTRA_PATH
)
814 CLEANUP
.append("src/wx.pth")
820 #----------------------------------------------------------------------
821 # Do the Setup/Build/Install/Whatever
822 #----------------------------------------------------------------------
824 if __name__
== "__main__":
827 setup(name
= 'wxPython',
829 description
= DESCRIPTION
,
830 long_description
= LONG_DESCRIPTION
,
832 author_email
= AUTHOR_EMAIL
,
834 download_url
= DOWNLOAD_URL
,
836 platforms
= PLATFORMS
,
837 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
840 packages
= ['wxPython',
842 'wxPython.lib.colourchooser',
843 'wxPython.lib.editor',
844 'wxPython.lib.mixins',
850 'wx.lib.analogclock',
851 'wx.lib.analogclock.lib_setup',
852 'wx.lib.colourchooser',
854 'wx.lib.floatcanvas',
863 extra_path
= EXTRA_PATH
,
865 ext_package
= PKGDIR
,
866 ext_modules
= wxpExtensions
,
868 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
872 data_files
= DATA_FILES
,
875 # Override some of the default distutils command classes with my own
876 cmdclass
= { 'install' : wx_install
,
877 'install_data': wx_smart_install_data
,
878 'install_headers': wx_install_headers
,
879 'clean': wx_extra_clean
,
883 setup(name
= 'wxaddons',
885 description
= DESCRIPTION
,
886 long_description
= LONG_DESCRIPTION
,
888 author_email
= AUTHOR_EMAIL
,
890 download_url
= DOWNLOAD_URL
,
892 platforms
= PLATFORMS
,
893 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
896 packages
= ['wxaddons']
899 if INSTALL_MULTIVERSION
:
900 setup(name
= 'wxPython-common',
902 description
= DESCRIPTION
,
903 long_description
= LONG_DESCRIPTION
,
905 author_email
= AUTHOR_EMAIL
,
907 download_url
= DOWNLOAD_URL
,
909 platforms
= PLATFORMS
,
910 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
913 package_dir
= { '': 'wxversion' }
,
914 py_modules
= ['wxversion'],
916 data_files
= [('', ['src/wx.pth'])],
918 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
921 cmdclass
= { 'install_data': wx_smart_install_data
,
925 #----------------------------------------------------------------------
926 #----------------------------------------------------------------------