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
)
461 #----------------------------------------------------------------------
462 # Define the GLCanvas extension module
463 #----------------------------------------------------------------------
466 msg('Preparing GLCANVAS...')
467 location
= 'contrib/glcanvas'
469 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
470 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
473 if os
.name
== 'posix':
474 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
475 gl_lflags
= gl_config
.split()
479 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
482 ext
= Extension('_glcanvas',
485 include_dirs
= includes
+ CONTRIBS_INC
,
486 define_macros
= defines
,
488 library_dirs
= libdirs
,
491 extra_compile_args
= cflags
,
492 extra_link_args
= gl_lflags
,
495 wxpExtensions
.append(ext
)
498 #----------------------------------------------------------------------
499 # Define the OGL extension module
500 #----------------------------------------------------------------------
503 msg('Preparing OGL...')
504 location
= 'contrib/ogl'
506 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
507 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
508 [ '%s/_oglbasic.i' % location
,
509 '%s/_oglshapes.i' % location
,
510 '%s/_oglshapes2.i' % location
,
511 '%s/_oglcanvas.i' % location
,
512 '%s/_ogldefs.i' % location
,
515 ext
= Extension('_ogl',
518 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
519 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
521 library_dirs
= libdirs
,
522 libraries
= libs
+ makeLibName('ogl'),
524 extra_compile_args
= cflags
,
525 extra_link_args
= lflags
,
528 wxpExtensions
.append(ext
)
532 #----------------------------------------------------------------------
533 # Define the STC extension module
534 #----------------------------------------------------------------------
537 msg('Preparing STC...')
538 location
= 'contrib/stc'
540 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
542 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
544 ## NOTE: need to add something like this to the stc.bkl...
546 ## # Check if gen_iface needs to be run for the wxSTC sources
547 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
548 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
549 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
551 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
553 ## os.chdir(opj(CTRB_SRC, 'stc'))
554 ## sys.path.insert(0, os.curdir)
556 ## gen_iface.main([])
560 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
561 USE_SWIG
, swig_force
,
562 swig_args
+ ['-I'+STC_H
, '-I'+location
],
563 [opj(STC_H
, 'stc.h'),
564 opj(location
, "_stc_utf8_methods.py"),
565 opj(location
, "_stc_docstrings.i"),
566 opj(location
, "_stc_gendocs.i"),
569 ext
= Extension('_stc',
572 include_dirs
= includes
+ CONTRIBS_INC
,
573 define_macros
= defines
,
575 library_dirs
= libdirs
,
576 libraries
= libs
+ makeLibName('stc'),
578 extra_compile_args
= cflags
,
579 extra_link_args
= lflags
,
582 wxpExtensions
.append(ext
)
585 #----------------------------------------------------------------------
586 # Define the ACTIVEX extension module (experimental)
587 #----------------------------------------------------------------------
590 msg('Preparing ACTIVEX...')
591 location
= 'contrib/activex'
592 axloc
= opj(location
, "wxie")
594 swig_files
= ['activex.i', ]
596 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
597 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
598 [ '%s/_activex_ex.py' % location
])
601 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
602 '%s/wxactivex.cpp' % axloc
,
605 include_dirs
= includes
+ [ axloc
],
606 define_macros
= defines
,
608 library_dirs
= libdirs
,
611 extra_compile_args
= cflags
,
612 extra_link_args
= lflags
,
615 wxpExtensions
.append(ext
)
618 #----------------------------------------------------------------------
619 # Define the GIZMOS extension module
620 #----------------------------------------------------------------------
623 msg('Preparing GIZMOS...')
624 location
= 'contrib/gizmos'
626 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
627 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
629 ext
= Extension('_gizmos',
630 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
632 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
633 define_macros
= defines
,
635 library_dirs
= libdirs
,
636 libraries
= libs
+ makeLibName('gizmos'),
638 extra_compile_args
= cflags
,
639 extra_link_args
= lflags
,
642 wxpExtensions
.append(ext
)
645 #----------------------------------------------------------------------
646 # Define the ANIMATE extension module
647 #----------------------------------------------------------------------
650 msg('Preparing ANIMATE...')
651 location
= 'contrib/animate'
653 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
654 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
656 ext
= Extension('_animate',
659 include_dirs
= includes
+ CONTRIBS_INC
,
660 define_macros
= defines
,
662 library_dirs
= libdirs
,
663 libraries
= libs
+ makeLibName('animate'),
665 extra_compile_args
= cflags
,
666 extra_link_args
= lflags
,
669 wxpExtensions
.append(ext
)
673 #----------------------------------------------------------------------
674 # Define the DLLWIDGET extension module
675 #----------------------------------------------------------------------
678 msg('Preparing DLLWIDGET...')
679 location
= 'contrib/dllwidget'
680 swig_files
= ['dllwidget_.i']
682 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
683 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
685 # copy a contrib project specific py module to the main package dir
686 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
687 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
689 ext
= Extension('dllwidget_c', [
690 '%s/dllwidget.cpp' % location
,
693 include_dirs
= includes
+ CONTRIBS_INC
,
694 define_macros
= defines
,
696 library_dirs
= libdirs
,
699 extra_compile_args
= cflags
,
700 extra_link_args
= lflags
,
703 wxpExtensions
.append(ext
)
708 #----------------------------------------------------------------------
709 # Tools, scripts data files, etc.
710 #----------------------------------------------------------------------
715 SCRIPTS
= [opj('scripts/helpviewer'),
716 opj('scripts/img2png'),
717 opj('scripts/img2py'),
718 opj('scripts/img2xpm'),
719 opj('scripts/pyalacarte'),
720 opj('scripts/pyalamode'),
721 opj('scripts/pycrust'),
722 opj('scripts/pyshell'),
723 opj('scripts/pywrap'),
724 opj('scripts/pywrap'),
725 opj('scripts/pywxrc'),
726 opj('scripts/xrced'),
731 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
732 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
733 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
739 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
740 i_files
= glob
.glob(opj("src/*.i")) + \
741 glob
.glob(opj("src/_*.py")) + \
742 glob
.glob(opj("src/*.swg"))
744 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
745 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
749 if INSTALL_MULTIVERSION
:
750 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
751 open("src/wx.pth", "w").write(EXTRA_PATH
)
752 CLEANUP
.append("src/wx.pth")
758 #----------------------------------------------------------------------
759 # Do the Setup/Build/Install/Whatever
760 #----------------------------------------------------------------------
762 if __name__
== "__main__":
765 setup(name
= 'wxPython',
767 description
= DESCRIPTION
,
768 long_description
= LONG_DESCRIPTION
,
770 author_email
= AUTHOR_EMAIL
,
772 download_url
= DOWNLOAD_URL
,
774 platforms
= PLATFORMS
,
775 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
778 packages
= ['wxPython',
780 'wx.lib.analogclock',
781 'wx.lib.analogclock.lib_setup',
782 'wxPython.lib.colourchooser',
783 'wxPython.lib.editor',
784 'wxPython.lib.mixins',
790 'wx.lib.colourchooser',
792 'wx.lib.floatcanvas',
801 extra_path
= EXTRA_PATH
,
803 ext_package
= PKGDIR
,
804 ext_modules
= wxpExtensions
,
806 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
810 data_files
= DATA_FILES
,
813 # Override some of the default distutils command classes with my own
814 cmdclass
= { 'install' : wx_install
,
815 'install_data': wx_smart_install_data
,
816 'install_headers': wx_install_headers
,
817 'clean': wx_extra_clean
,
822 if INSTALL_MULTIVERSION
:
823 setup(name
= 'wxPython-common',
825 description
= DESCRIPTION
,
826 long_description
= LONG_DESCRIPTION
,
828 author_email
= AUTHOR_EMAIL
,
830 download_url
= DOWNLOAD_URL
,
832 platforms
= PLATFORMS
,
833 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
836 package_dir
= { '': 'wxversion' }
,
837 py_modules
= ['wxversion'],
839 data_files
= [('', ['src/wx.pth'])],
841 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
844 cmdclass
= { 'install_data': wx_smart_install_data
,
848 #----------------------------------------------------------------------
849 #----------------------------------------------------------------------