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',
212 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
213 include_dirs
= includes
,
214 define_macros
= defines
,
215 library_dirs
= libdirs
,
217 extra_compile_args
= cflags
,
218 extra_link_args
= lflags
,
221 wxpExtensions
.append(ext
)
228 # Extension for the windows module
229 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
230 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
231 ['src/__windows_rename.i',
232 'src/__windows_reverse.txt',
248 ext
= Extension('_windows_', swig_sources
,
249 include_dirs
= includes
,
250 define_macros
= defines
,
251 library_dirs
= libdirs
,
253 extra_compile_args
= cflags
,
254 extra_link_args
= lflags
,
257 wxpExtensions
.append(ext
)
262 # Extension for the controls module
263 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
264 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
265 [ 'src/__controls_rename.i',
266 'src/__controls_reverse.txt',
291 ext
= Extension('_controls_', swig_sources
,
292 include_dirs
= includes
,
293 define_macros
= defines
,
294 library_dirs
= libdirs
,
296 extra_compile_args
= cflags
,
297 extra_link_args
= lflags
,
300 wxpExtensions
.append(ext
)
305 # Extension for the misc module
306 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
307 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
308 [ 'src/__misc_rename.i',
309 'src/__misc_reverse.txt',
330 ext
= Extension('_misc_', swig_sources
,
331 include_dirs
= includes
,
332 define_macros
= defines
,
333 library_dirs
= libdirs
,
335 extra_compile_args
= cflags
,
336 extra_link_args
= lflags
,
339 wxpExtensions
.append(ext
)
344 ## Core modules that are not in the "core" namespace start here
347 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
348 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
349 ext
= Extension('_calendar', swig_sources
,
350 include_dirs
= includes
,
351 define_macros
= defines
,
352 library_dirs
= libdirs
,
354 extra_compile_args
= cflags
,
355 extra_link_args
= lflags
,
358 wxpExtensions
.append(ext
)
361 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
362 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
363 ext
= Extension('_grid', swig_sources
,
364 include_dirs
= includes
,
365 define_macros
= defines
,
366 library_dirs
= libdirs
,
368 extra_compile_args
= cflags
,
369 extra_link_args
= lflags
,
372 wxpExtensions
.append(ext
)
376 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
377 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
378 ext
= Extension('_html', swig_sources
,
379 include_dirs
= includes
,
380 define_macros
= defines
,
381 library_dirs
= libdirs
,
383 extra_compile_args
= cflags
,
384 extra_link_args
= lflags
,
387 wxpExtensions
.append(ext
)
391 if not MONOLITHIC
and os
.name
== 'nt':
392 mediaLibs
.append(makeLibName('media')[0])
393 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
394 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
395 ext
= Extension('_media', swig_sources
,
396 include_dirs
= includes
,
397 define_macros
= defines
,
398 library_dirs
= libdirs
,
399 libraries
= mediaLibs
,
400 extra_compile_args
= cflags
,
401 extra_link_args
= lflags
,
404 wxpExtensions
.append(ext
)
407 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
408 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
409 ext
= Extension('_webkit', swig_sources
,
410 include_dirs
= includes
,
411 define_macros
= defines
,
412 library_dirs
= libdirs
,
414 extra_compile_args
= cflags
,
415 extra_link_args
= lflags
,
418 wxpExtensions
.append(ext
)
422 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
423 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
424 ext
= Extension('_wizard', swig_sources
,
425 include_dirs
= includes
,
426 define_macros
= defines
,
427 library_dirs
= libdirs
,
429 extra_compile_args
= cflags
,
430 extra_link_args
= lflags
,
433 wxpExtensions
.append(ext
)
437 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
438 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
439 [ 'src/_xrc_rename.i',
446 ext
= Extension('_xrc',
449 include_dirs
= includes
+ CONTRIBS_INC
,
450 define_macros
= defines
,
452 library_dirs
= libdirs
,
455 extra_compile_args
= cflags
,
456 extra_link_args
= lflags
,
458 wxpExtensions
.append(ext
)
462 swig_sources
= run_swig(['richtext.i'], 'src', GENDIR
, PKGDIR
,
463 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
464 ext
= Extension('_richtext', swig_sources
,
465 include_dirs
= includes
,
466 define_macros
= defines
,
467 library_dirs
= libdirs
,
469 extra_compile_args
= cflags
,
470 extra_link_args
= lflags
,
473 wxpExtensions
.append(ext
)
479 #----------------------------------------------------------------------
480 # Define the GLCanvas extension module
481 #----------------------------------------------------------------------
484 msg('Preparing GLCANVAS...')
485 location
= 'contrib/glcanvas'
487 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
488 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
491 if os
.name
== 'posix':
492 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
493 gl_lflags
= gl_config
.split()
497 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
500 ext
= Extension('_glcanvas',
503 include_dirs
= includes
+ CONTRIBS_INC
,
504 define_macros
= defines
,
506 library_dirs
= libdirs
,
509 extra_compile_args
= cflags
,
510 extra_link_args
= gl_lflags
,
513 wxpExtensions
.append(ext
)
516 #----------------------------------------------------------------------
517 # Define the OGL extension module
518 #----------------------------------------------------------------------
521 msg('Preparing OGL...')
522 location
= 'contrib/ogl'
524 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
525 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
526 [ '%s/_oglbasic.i' % location
,
527 '%s/_oglshapes.i' % location
,
528 '%s/_oglshapes2.i' % location
,
529 '%s/_oglcanvas.i' % location
,
530 '%s/_ogldefs.i' % location
,
533 ext
= Extension('_ogl',
536 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
537 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
539 library_dirs
= libdirs
,
540 libraries
= libs
+ makeLibName('ogl'),
542 extra_compile_args
= cflags
,
543 extra_link_args
= lflags
,
546 wxpExtensions
.append(ext
)
550 #----------------------------------------------------------------------
551 # Define the STC extension module
552 #----------------------------------------------------------------------
555 msg('Preparing STC...')
556 location
= 'contrib/stc'
558 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
560 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
562 ## NOTE: need to add something like this to the stc.bkl...
564 ## # Check if gen_iface needs to be run for the wxSTC sources
565 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
566 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
567 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
569 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
571 ## os.chdir(opj(CTRB_SRC, 'stc'))
572 ## sys.path.insert(0, os.curdir)
574 ## gen_iface.main([])
578 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
579 USE_SWIG
, swig_force
,
580 swig_args
+ ['-I'+STC_H
, '-I'+location
],
581 [opj(STC_H
, 'stc.h'),
582 opj(location
, "_stc_utf8_methods.py"),
583 opj(location
, "_stc_docstrings.i"),
584 opj(location
, "_stc_gendocs.i"),
587 ext
= Extension('_stc',
590 include_dirs
= includes
+ CONTRIBS_INC
,
591 define_macros
= defines
,
593 library_dirs
= libdirs
,
594 libraries
= libs
+ makeLibName('stc'),
596 extra_compile_args
= cflags
,
597 extra_link_args
= lflags
,
600 wxpExtensions
.append(ext
)
603 #----------------------------------------------------------------------
604 # Define the ACTIVEX extension module (experimental)
605 #----------------------------------------------------------------------
608 msg('Preparing ACTIVEX...')
609 location
= 'contrib/activex'
610 axloc
= opj(location
, "wxie")
612 swig_files
= ['activex.i', ]
614 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
615 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
616 [ '%s/_activex_ex.py' % location
])
619 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
620 '%s/wxactivex.cpp' % axloc
,
623 include_dirs
= includes
+ [ axloc
],
624 define_macros
= defines
,
626 library_dirs
= libdirs
,
629 extra_compile_args
= cflags
,
630 extra_link_args
= lflags
,
633 wxpExtensions
.append(ext
)
636 #----------------------------------------------------------------------
637 # Define the GIZMOS extension module
638 #----------------------------------------------------------------------
641 msg('Preparing GIZMOS...')
642 location
= 'contrib/gizmos'
644 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
645 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
647 ext
= Extension('_gizmos',
648 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
650 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
651 define_macros
= defines
,
653 library_dirs
= libdirs
,
654 libraries
= libs
+ makeLibName('gizmos'),
656 extra_compile_args
= cflags
,
657 extra_link_args
= lflags
,
660 wxpExtensions
.append(ext
)
663 #----------------------------------------------------------------------
664 # Define the ANIMATE extension module
665 #----------------------------------------------------------------------
668 msg('Preparing ANIMATE...')
669 location
= 'contrib/animate'
671 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
672 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
674 ext
= Extension('_animate',
677 include_dirs
= includes
+ CONTRIBS_INC
,
678 define_macros
= defines
,
680 library_dirs
= libdirs
,
681 libraries
= libs
+ makeLibName('animate'),
683 extra_compile_args
= cflags
,
684 extra_link_args
= lflags
,
687 wxpExtensions
.append(ext
)
691 #----------------------------------------------------------------------
692 # Define the DLLWIDGET extension module
693 #----------------------------------------------------------------------
696 msg('Preparing DLLWIDGET...')
697 location
= 'contrib/dllwidget'
698 swig_files
= ['dllwidget_.i']
700 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
701 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
703 # copy a contrib project specific py module to the main package dir
704 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
705 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
707 ext
= Extension('dllwidget_c', [
708 '%s/dllwidget.cpp' % location
,
711 include_dirs
= includes
+ CONTRIBS_INC
,
712 define_macros
= defines
,
714 library_dirs
= libdirs
,
717 extra_compile_args
= cflags
,
718 extra_link_args
= lflags
,
721 wxpExtensions
.append(ext
)
726 #----------------------------------------------------------------------
727 # Tools, scripts data files, etc.
728 #----------------------------------------------------------------------
733 SCRIPTS
= [opj('scripts/helpviewer'),
734 opj('scripts/img2png'),
735 opj('scripts/img2py'),
736 opj('scripts/img2xpm'),
737 opj('scripts/pyalacarte'),
738 opj('scripts/pyalamode'),
739 opj('scripts/pycrust'),
740 opj('scripts/pyshell'),
741 opj('scripts/pywrap'),
742 opj('scripts/pywrap'),
743 opj('scripts/pywxrc'),
744 opj('scripts/xrced'),
749 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
750 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
751 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
757 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
758 i_files
= glob
.glob(opj("src/*.i")) + \
759 glob
.glob(opj("src/_*.py")) + \
760 glob
.glob(opj("src/*.swg"))
762 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
763 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
767 if INSTALL_MULTIVERSION
:
768 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
769 open("src/wx.pth", "w").write(EXTRA_PATH
)
770 CLEANUP
.append("src/wx.pth")
776 #----------------------------------------------------------------------
777 # Do the Setup/Build/Install/Whatever
778 #----------------------------------------------------------------------
780 if __name__
== "__main__":
783 setup(name
= 'wxPython',
785 description
= DESCRIPTION
,
786 long_description
= LONG_DESCRIPTION
,
788 author_email
= AUTHOR_EMAIL
,
790 download_url
= DOWNLOAD_URL
,
792 platforms
= PLATFORMS
,
793 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
796 packages
= ['wxPython',
798 'wxPython.lib.colourchooser',
799 'wxPython.lib.editor',
800 'wxPython.lib.mixins',
806 'wx.lib.analogclock',
807 'wx.lib.analogclock.lib_setup',
808 'wx.lib.colourchooser',
810 'wx.lib.floatcanvas',
819 extra_path
= EXTRA_PATH
,
821 ext_package
= PKGDIR
,
822 ext_modules
= wxpExtensions
,
824 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
828 data_files
= DATA_FILES
,
831 # Override some of the default distutils command classes with my own
832 cmdclass
= { 'install' : wx_install
,
833 'install_data': wx_smart_install_data
,
834 'install_headers': wx_install_headers
,
835 'clean': wx_extra_clean
,
840 if INSTALL_MULTIVERSION
:
841 setup(name
= 'wxPython-common',
843 description
= DESCRIPTION
,
844 long_description
= LONG_DESCRIPTION
,
846 author_email
= AUTHOR_EMAIL
,
848 download_url
= DOWNLOAD_URL
,
850 platforms
= PLATFORMS
,
851 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
854 package_dir
= { '': 'wxversion' }
,
855 py_modules
= ['wxversion'],
857 data_files
= [('', ['src/wx.pth'])],
859 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
862 cmdclass
= { 'install_data': wx_smart_install_data
,
866 #----------------------------------------------------------------------
867 #----------------------------------------------------------------------