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',
215 ext
= Extension('_gdi_', ['src/drawlist.cpp',
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
)
233 # Extension for the windows module
234 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
235 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
236 ['src/__windows_rename.i',
237 'src/__windows_reverse.txt',
253 ext
= Extension('_windows_', swig_sources
,
254 include_dirs
= includes
,
255 define_macros
= defines
,
256 library_dirs
= libdirs
,
258 extra_compile_args
= cflags
,
259 extra_link_args
= lflags
,
262 wxpExtensions
.append(ext
)
267 # Extension for the controls module
268 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
269 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
270 [ 'src/__controls_rename.i',
271 'src/__controls_reverse.txt',
298 ext
= Extension('_controls_', 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 # Extension for the misc module
313 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
314 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
315 [ 'src/__misc_rename.i',
316 'src/__misc_reverse.txt',
339 ext
= Extension('_misc_', swig_sources
,
340 include_dirs
= includes
,
341 define_macros
= defines
,
342 library_dirs
= libdirs
,
344 extra_compile_args
= cflags
,
345 extra_link_args
= lflags
,
348 wxpExtensions
.append(ext
)
353 ## Core modules that are not in the "core" namespace start here
356 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
357 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
358 ext
= Extension('_calendar', swig_sources
,
359 include_dirs
= includes
,
360 define_macros
= defines
,
361 library_dirs
= libdirs
,
363 extra_compile_args
= cflags
,
364 extra_link_args
= lflags
,
367 wxpExtensions
.append(ext
)
370 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
371 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
372 ext
= Extension('_grid', swig_sources
,
373 include_dirs
= includes
,
374 define_macros
= defines
,
375 library_dirs
= libdirs
,
377 extra_compile_args
= cflags
,
378 extra_link_args
= lflags
,
381 wxpExtensions
.append(ext
)
385 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
386 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
387 ext
= Extension('_html', swig_sources
,
388 include_dirs
= includes
,
389 define_macros
= defines
,
390 library_dirs
= libdirs
,
392 extra_compile_args
= cflags
,
393 extra_link_args
= lflags
,
396 wxpExtensions
.append(ext
)
401 mediaLibs
+= makeLibName('media')
402 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
403 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
404 ext
= Extension('_media', swig_sources
,
405 include_dirs
= includes
,
406 define_macros
= defines
,
407 library_dirs
= libdirs
,
408 libraries
= mediaLibs
,
409 extra_compile_args
= cflags
,
410 extra_link_args
= lflags
,
413 wxpExtensions
.append(ext
)
416 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
417 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
418 ext
= Extension('_webkit', swig_sources
,
419 include_dirs
= includes
,
420 define_macros
= defines
,
421 library_dirs
= libdirs
,
423 extra_compile_args
= cflags
,
424 extra_link_args
= lflags
,
427 wxpExtensions
.append(ext
)
431 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
432 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
433 ext
= Extension('_wizard', swig_sources
,
434 include_dirs
= includes
,
435 define_macros
= defines
,
436 library_dirs
= libdirs
,
438 extra_compile_args
= cflags
,
439 extra_link_args
= lflags
,
442 wxpExtensions
.append(ext
)
446 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
447 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
448 [ 'src/_xrc_rename.i',
456 xrcLib
= makeLibName('xrc')
459 ext
= Extension('_xrc',
462 include_dirs
= includes
+ CONTRIBS_INC
,
463 define_macros
= defines
,
465 library_dirs
= libdirs
,
466 libraries
= libs
+ xrcLib
,
468 extra_compile_args
= cflags
,
469 extra_link_args
= lflags
,
471 wxpExtensions
.append(ext
)
475 swig_sources
= run_swig(['richtext.i'], 'src', GENDIR
, PKGDIR
,
476 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
478 richLib
= makeLibName('richtext')
481 ext
= Extension('_richtext', swig_sources
,
482 include_dirs
= includes
,
483 define_macros
= defines
,
484 library_dirs
= libdirs
,
485 libraries
= libs
+ richLib
,
486 extra_compile_args
= cflags
,
487 extra_link_args
= lflags
,
490 wxpExtensions
.append(ext
)
494 swig_sources
= run_swig(['aui.i'], 'src', GENDIR
, PKGDIR
,
495 USE_SWIG
, swig_force
,
496 swig_args
+ ['-I'+opj(WXDIR
, 'include/wx/aui')],
497 swig_deps
+ ['src/_aui_docstrings.i',
498 opj(WXDIR
, 'include/wx/aui/framemanager.h'),
499 opj(WXDIR
, 'include/wx/aui/floatpane.h'),
500 opj(WXDIR
, 'include/wx/aui/dockart.h'),
501 opj(WXDIR
, 'include/wx/aui/auibook.h'),
504 auiLib
= makeLibName('aui')
507 ext
= Extension('_aui', swig_sources
,
508 include_dirs
= includes
,
509 define_macros
= defines
,
510 library_dirs
= libdirs
,
511 libraries
= libs
+ auiLib
,
512 extra_compile_args
= cflags
,
513 extra_link_args
= lflags
,
516 wxpExtensions
.append(ext
)
519 swig_sources
= run_swig(['animate.i'], 'src', GENDIR
, PKGDIR
,
520 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
521 ext
= Extension('_animate',
524 include_dirs
= includes
+ CONTRIBS_INC
,
525 define_macros
= defines
,
527 library_dirs
= libdirs
,
530 extra_compile_args
= cflags
,
531 extra_link_args
= lflags
,
534 wxpExtensions
.append(ext
)
539 #----------------------------------------------------------------------
540 # Define the GLCanvas extension module
541 #----------------------------------------------------------------------
544 msg('Preparing GLCANVAS...')
545 location
= 'contrib/glcanvas'
547 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
548 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
551 gl_libdirs
= libdirs
[:]
552 if os
.name
== 'posix':
553 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
554 gl_lflags
= gl_config
.split()
555 gl_lflags
= adjustLFLAGS(gl_lflags
, gl_libdirs
, gl_libs
)
559 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
562 ext
= Extension('_glcanvas',
565 include_dirs
= includes
+ CONTRIBS_INC
,
566 define_macros
= defines
,
568 library_dirs
= gl_libdirs
,
571 extra_compile_args
= cflags
,
572 extra_link_args
= gl_lflags
,
575 wxpExtensions
.append(ext
)
578 #----------------------------------------------------------------------
579 # Define the OGL extension module
580 #----------------------------------------------------------------------
583 msg('Preparing OGL...')
584 location
= 'contrib/ogl'
586 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
587 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
588 [ '%s/_oglbasic.i' % location
,
589 '%s/_oglshapes.i' % location
,
590 '%s/_oglshapes2.i' % location
,
591 '%s/_oglcanvas.i' % location
,
592 '%s/_ogldefs.i' % location
,
595 ext
= Extension('_ogl',
598 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
599 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
601 library_dirs
= libdirs
,
602 libraries
= libs
+ makeLibName('ogl'),
604 extra_compile_args
= cflags
,
605 extra_link_args
= lflags
,
608 wxpExtensions
.append(ext
)
612 #----------------------------------------------------------------------
613 # Define the STC extension module
614 #----------------------------------------------------------------------
617 msg('Preparing STC...')
618 location
= 'contrib/stc'
620 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
622 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
624 ## NOTE: need to add something like this to the stc.bkl...
626 ## # Check if gen_iface needs to be run for the wxSTC sources
627 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
628 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
629 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
631 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
633 ## os.chdir(opj(CTRB_SRC, 'stc'))
634 ## sys.path.insert(0, os.curdir)
636 ## gen_iface.main([])
640 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
641 USE_SWIG
, swig_force
,
642 swig_args
+ ['-I'+STC_H
, '-I'+location
],
643 [opj(STC_H
, 'stc.h'),
644 opj(location
, "_stc_utf8_methods.py"),
645 opj(location
, "_stc_docstrings.i"),
646 opj(location
, "_stc_gendocs.i"),
649 ext
= Extension('_stc',
652 include_dirs
= includes
+ CONTRIBS_INC
,
653 define_macros
= defines
,
655 library_dirs
= libdirs
,
656 libraries
= libs
+ makeLibName('stc'),
658 extra_compile_args
= cflags
,
659 extra_link_args
= lflags
,
662 wxpExtensions
.append(ext
)
665 #----------------------------------------------------------------------
666 # Define the ACTIVEX extension module (experimental)
667 #----------------------------------------------------------------------
670 msg('Preparing ACTIVEX...')
671 location
= 'contrib/activex'
672 axloc
= opj(location
, "wxie")
674 swig_files
= ['activex.i', ]
676 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
677 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
678 [ '%s/_activex_ex.py' % location
])
681 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
682 '%s/wxactivex.cpp' % axloc
,
685 include_dirs
= includes
+ [ axloc
],
686 define_macros
= defines
,
688 library_dirs
= libdirs
,
691 extra_compile_args
= cflags
,
692 extra_link_args
= lflags
,
695 wxpExtensions
.append(ext
)
698 #----------------------------------------------------------------------
699 # Define the GIZMOS extension module
700 #----------------------------------------------------------------------
703 msg('Preparing GIZMOS...')
704 location
= 'contrib/gizmos'
706 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
707 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
708 [ '%s/_treelist.i' % location
])
710 ext
= Extension('_gizmos',
711 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
713 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
714 define_macros
= defines
,
716 library_dirs
= libdirs
,
717 libraries
= libs
+ makeLibName('gizmos'),
719 extra_compile_args
= cflags
,
720 extra_link_args
= lflags
,
723 wxpExtensions
.append(ext
)
726 #----------------------------------------------------------------------
727 # Define the DLLWIDGET extension module
728 #----------------------------------------------------------------------
731 msg('Preparing DLLWIDGET...')
732 location
= 'contrib/dllwidget'
733 swig_files
= ['dllwidget_.i']
735 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
736 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
738 # copy a contrib project specific py module to the main package dir
739 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
740 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
742 ext
= Extension('dllwidget_c', [
743 '%s/dllwidget.cpp' % location
,
746 include_dirs
= includes
+ CONTRIBS_INC
,
747 define_macros
= defines
,
749 library_dirs
= libdirs
,
752 extra_compile_args
= cflags
,
753 extra_link_args
= lflags
,
756 wxpExtensions
.append(ext
)
761 #----------------------------------------------------------------------
762 # Tools, scripts data files, etc.
763 #----------------------------------------------------------------------
768 SCRIPTS
= [opj('scripts/helpviewer'),
769 opj('scripts/img2png'),
770 opj('scripts/img2py'),
771 opj('scripts/img2xpm'),
772 opj('scripts/pyalacarte'),
773 opj('scripts/pyalamode'),
774 opj('scripts/pycrust'),
775 opj('scripts/pyshell'),
776 opj('scripts/pywrap'),
777 opj('scripts/pywrap'),
778 opj('scripts/pywxrc'),
779 opj('scripts/xrced'),
784 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
785 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
786 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
792 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
793 i_files
= glob
.glob(opj("src/*.i")) + \
794 glob
.glob(opj("src/_*.py")) + \
795 glob
.glob(opj("src/*.swg"))
797 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
798 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
802 if INSTALL_MULTIVERSION
:
803 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
804 open("src/wx.pth", "w").write(EXTRA_PATH
)
805 CLEANUP
.append("src/wx.pth")
811 #----------------------------------------------------------------------
812 # Do the Setup/Build/Install/Whatever
813 #----------------------------------------------------------------------
815 if __name__
== "__main__":
818 setup(name
= 'wxPython',
820 description
= DESCRIPTION
,
821 long_description
= LONG_DESCRIPTION
,
823 author_email
= AUTHOR_EMAIL
,
825 download_url
= DOWNLOAD_URL
,
827 platforms
= PLATFORMS
,
828 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
831 packages
= ['wxPython',
833 'wxPython.lib.colourchooser',
834 'wxPython.lib.editor',
835 'wxPython.lib.mixins',
841 'wx.lib.analogclock',
842 'wx.lib.analogclock.lib_setup',
843 'wx.lib.colourchooser',
845 'wx.lib.floatcanvas',
854 extra_path
= EXTRA_PATH
,
856 ext_package
= PKGDIR
,
857 ext_modules
= wxpExtensions
,
859 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
863 data_files
= DATA_FILES
,
866 # Override some of the default distutils command classes with my own
867 cmdclass
= { 'install' : wx_install
,
868 'install_data': wx_smart_install_data
,
869 'install_headers': wx_install_headers
,
870 'clean': wx_extra_clean
,
874 setup(name
= 'wxaddons',
876 description
= DESCRIPTION
,
877 long_description
= LONG_DESCRIPTION
,
879 author_email
= AUTHOR_EMAIL
,
881 download_url
= DOWNLOAD_URL
,
883 platforms
= PLATFORMS
,
884 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
887 packages
= ['wxaddons']
890 if INSTALL_MULTIVERSION
:
891 setup(name
= 'wxPython-common',
893 description
= DESCRIPTION
,
894 long_description
= LONG_DESCRIPTION
,
896 author_email
= AUTHOR_EMAIL
,
898 download_url
= DOWNLOAD_URL
,
900 platforms
= PLATFORMS
,
901 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
904 package_dir
= { '': 'wxversion' }
,
905 py_modules
= ['wxversion'],
907 data_files
= [('', ['src/wx.pth'])],
909 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
912 cmdclass
= { 'install_data': wx_smart_install_data
,
916 #----------------------------------------------------------------------
917 #----------------------------------------------------------------------