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 # patch distutils if it can't cope with the "classifiers" or
81 # "download_url" keywords
82 #----------------------------------------------------------------------
84 if sys
.version
< '2.2.3':
85 from distutils
.dist
import DistributionMetadata
86 DistributionMetadata
.classifiers
= None
87 DistributionMetadata
.download_url
= None
90 depends
= {'depends' : depends}
93 #----------------------------------------------------------------------
94 # Define the CORE extension module
95 #----------------------------------------------------------------------
97 msg('Preparing CORE...')
98 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
99 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
103 'src/_constraints.i',
106 'src/__core_rename.i',
107 'src/__core_reverse.txt',
127 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
128 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
131 # update the license files
133 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
134 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
135 CLEANUP
.append(opj('licence',file))
136 CLEANUP
.append('licence')
140 build_locale_dir(opj(PKGDIR
, 'locale'))
141 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
145 rc_file
= ['src/wxc.rc']
150 ext
= Extension('_core_', ['src/helpers.cpp',
151 ] + rc_file
+ swig_sources
,
153 include_dirs
= includes
,
154 define_macros
= defines
,
156 library_dirs
= libdirs
,
159 extra_compile_args
= cflags
,
160 extra_link_args
= lflags
,
164 wxpExtensions
.append(ext
)
170 # Extension for the GDI module
171 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
172 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
173 ['src/__gdi_rename.i',
193 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
194 include_dirs
= includes
,
195 define_macros
= defines
,
196 library_dirs
= libdirs
,
198 extra_compile_args
= cflags
,
199 extra_link_args
= lflags
,
202 wxpExtensions
.append(ext
)
209 # Extension for the windows module
210 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
211 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
212 ['src/__windows_rename.i',
213 'src/__windows_reverse.txt',
229 ext
= Extension('_windows_', swig_sources
,
230 include_dirs
= includes
,
231 define_macros
= defines
,
232 library_dirs
= libdirs
,
234 extra_compile_args
= cflags
,
235 extra_link_args
= lflags
,
238 wxpExtensions
.append(ext
)
243 # Extension for the controls module
244 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
245 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
246 [ 'src/__controls_rename.i',
247 'src/__controls_reverse.txt',
272 ext
= Extension('_controls_', swig_sources
,
273 include_dirs
= includes
,
274 define_macros
= defines
,
275 library_dirs
= libdirs
,
277 extra_compile_args
= cflags
,
278 extra_link_args
= lflags
,
281 wxpExtensions
.append(ext
)
286 # Extension for the misc module
287 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
288 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
289 [ 'src/__misc_rename.i',
290 'src/__misc_reverse.txt',
311 ext
= Extension('_misc_', swig_sources
,
312 include_dirs
= includes
,
313 define_macros
= defines
,
314 library_dirs
= libdirs
,
316 extra_compile_args
= cflags
,
317 extra_link_args
= lflags
,
320 wxpExtensions
.append(ext
)
325 ## Core modules that are not in the "core" namespace start here
328 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
329 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
330 ext
= Extension('_calendar', 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
)
342 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
343 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
344 ext
= Extension('_grid', swig_sources
,
345 include_dirs
= includes
,
346 define_macros
= defines
,
347 library_dirs
= libdirs
,
349 extra_compile_args
= cflags
,
350 extra_link_args
= lflags
,
353 wxpExtensions
.append(ext
)
357 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
358 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
359 ext
= Extension('_html', swig_sources
,
360 include_dirs
= includes
,
361 define_macros
= defines
,
362 library_dirs
= libdirs
,
364 extra_compile_args
= cflags
,
365 extra_link_args
= lflags
,
368 wxpExtensions
.append(ext
)
372 if not MONOLITHIC
and os
.name
== 'nt':
373 mediaLibs
.append(makeLibName('media')[0])
374 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
375 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
376 ext
= Extension('_media', swig_sources
,
377 include_dirs
= includes
,
378 define_macros
= defines
,
379 library_dirs
= libdirs
,
380 libraries
= mediaLibs
,
381 extra_compile_args
= cflags
,
382 extra_link_args
= lflags
,
385 wxpExtensions
.append(ext
)
388 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
389 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
390 ext
= Extension('_webkit', swig_sources
,
391 include_dirs
= includes
,
392 define_macros
= defines
,
393 library_dirs
= libdirs
,
395 extra_compile_args
= cflags
,
396 extra_link_args
= lflags
,
399 wxpExtensions
.append(ext
)
403 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
404 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
405 ext
= Extension('_wizard', swig_sources
,
406 include_dirs
= includes
,
407 define_macros
= defines
,
408 library_dirs
= libdirs
,
410 extra_compile_args
= cflags
,
411 extra_link_args
= lflags
,
414 wxpExtensions
.append(ext
)
418 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
419 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
420 [ 'src/_xrc_rename.i',
427 ext
= Extension('_xrc',
430 include_dirs
= includes
+ CONTRIBS_INC
,
431 define_macros
= defines
,
433 library_dirs
= libdirs
,
436 extra_compile_args
= cflags
,
437 extra_link_args
= lflags
,
439 wxpExtensions
.append(ext
)
442 #----------------------------------------------------------------------
443 # Define the GLCanvas extension module
444 #----------------------------------------------------------------------
447 msg('Preparing GLCANVAS...')
448 location
= 'contrib/glcanvas'
450 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
451 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
454 if os
.name
== 'posix':
455 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
456 gl_lflags
= gl_config
.split() + lflags
459 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
462 ext
= Extension('_glcanvas',
465 include_dirs
= includes
+ CONTRIBS_INC
,
466 define_macros
= defines
,
468 library_dirs
= libdirs
,
471 extra_compile_args
= cflags
,
472 extra_link_args
= gl_lflags
,
475 wxpExtensions
.append(ext
)
478 #----------------------------------------------------------------------
479 # Define the OGL extension module
480 #----------------------------------------------------------------------
483 msg('Preparing OGL...')
484 location
= 'contrib/ogl'
486 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
487 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
488 [ '%s/_oglbasic.i' % location
,
489 '%s/_oglshapes.i' % location
,
490 '%s/_oglshapes2.i' % location
,
491 '%s/_oglcanvas.i' % location
,
492 '%s/_ogldefs.i' % location
,
495 ext
= Extension('_ogl',
498 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
499 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
501 library_dirs
= libdirs
,
502 libraries
= libs
+ makeLibName('ogl'),
504 extra_compile_args
= cflags
,
505 extra_link_args
= lflags
,
508 wxpExtensions
.append(ext
)
512 #----------------------------------------------------------------------
513 # Define the STC extension module
514 #----------------------------------------------------------------------
517 msg('Preparing STC...')
518 location
= 'contrib/stc'
520 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
522 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
524 ## NOTE: need to add something like this to the stc.bkl...
526 ## # Check if gen_iface needs to be run for the wxSTC sources
527 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
528 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
529 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
531 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
533 ## os.chdir(opj(CTRB_SRC, 'stc'))
534 ## sys.path.insert(0, os.curdir)
536 ## gen_iface.main([])
540 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
541 USE_SWIG
, swig_force
,
542 swig_args
+ ['-I'+STC_H
, '-I'+location
],
543 [opj(STC_H
, 'stc.h'),
544 opj(location
, "_stc_utf8_methods.py"),
545 opj(location
, "_stc_docstrings.i"),
546 opj(location
, "_stc_gendocs.i"),
549 ext
= Extension('_stc',
552 include_dirs
= includes
+ CONTRIBS_INC
,
553 define_macros
= defines
,
555 library_dirs
= libdirs
,
556 libraries
= libs
+ makeLibName('stc'),
558 extra_compile_args
= cflags
,
559 extra_link_args
= lflags
,
562 wxpExtensions
.append(ext
)
565 #----------------------------------------------------------------------
566 # Define the ACTIVEX extension module (experimental)
567 #----------------------------------------------------------------------
570 msg('Preparing ACTIVEX...')
571 location
= 'contrib/activex'
572 axloc
= opj(location
, "wxie")
574 swig_files
= ['activex.i', ]
576 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
577 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
578 [ '%s/_activex_ex.py' % location
])
581 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
582 '%s/wxactivex.cpp' % axloc
,
585 include_dirs
= includes
+ [ axloc
],
586 define_macros
= defines
,
588 library_dirs
= libdirs
,
591 extra_compile_args
= cflags
,
592 extra_link_args
= lflags
,
595 wxpExtensions
.append(ext
)
598 #----------------------------------------------------------------------
599 # Define the GIZMOS extension module
600 #----------------------------------------------------------------------
603 msg('Preparing GIZMOS...')
604 location
= 'contrib/gizmos'
606 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
607 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
609 ext
= Extension('_gizmos',
610 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
612 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
613 define_macros
= defines
,
615 library_dirs
= libdirs
,
616 libraries
= libs
+ makeLibName('gizmos'),
618 extra_compile_args
= cflags
,
619 extra_link_args
= lflags
,
622 wxpExtensions
.append(ext
)
625 #----------------------------------------------------------------------
626 # Define the ANIMATE extension module
627 #----------------------------------------------------------------------
630 msg('Preparing ANIMATE...')
631 location
= 'contrib/animate'
633 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
634 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
636 ext
= Extension('_animate',
639 include_dirs
= includes
+ CONTRIBS_INC
,
640 define_macros
= defines
,
642 library_dirs
= libdirs
,
643 libraries
= libs
+ makeLibName('animate'),
645 extra_compile_args
= cflags
,
646 extra_link_args
= lflags
,
649 wxpExtensions
.append(ext
)
653 #----------------------------------------------------------------------
654 # Define the DLLWIDGET extension module
655 #----------------------------------------------------------------------
658 msg('Preparing DLLWIDGET...')
659 location
= 'contrib/dllwidget'
660 swig_files
= ['dllwidget_.i']
662 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
663 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
665 # copy a contrib project specific py module to the main package dir
666 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
667 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
669 ext
= Extension('dllwidget_c', [
670 '%s/dllwidget.cpp' % location
,
673 include_dirs
= includes
+ CONTRIBS_INC
,
674 define_macros
= defines
,
676 library_dirs
= libdirs
,
679 extra_compile_args
= cflags
,
680 extra_link_args
= lflags
,
683 wxpExtensions
.append(ext
)
688 #----------------------------------------------------------------------
689 # Tools, scripts data files, etc.
690 #----------------------------------------------------------------------
695 SCRIPTS
= [opj('scripts/helpviewer'),
696 opj('scripts/img2png'),
697 opj('scripts/img2py'),
698 opj('scripts/img2xpm'),
699 opj('scripts/pyalacarte'),
700 opj('scripts/pyalamode'),
701 opj('scripts/pycrust'),
702 opj('scripts/pyshell'),
703 opj('scripts/pywrap'),
704 opj('scripts/pywrap'),
705 opj('scripts/pywxrc'),
706 opj('scripts/xrced'),
711 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
712 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
713 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
719 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
720 i_files
= glob
.glob(opj("src/*.i")) + \
721 glob
.glob(opj("src/_*.py")) + \
722 glob
.glob(opj("src/*.swg"))
724 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
725 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
729 if INSTALL_MULTIVERSION
:
730 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
)
731 open("src/wx.pth", "w").write(EXTRA_PATH
)
732 CLEANUP
.append("src/wx.pth")
738 #----------------------------------------------------------------------
739 # Do the Setup/Build/Install/Whatever
740 #----------------------------------------------------------------------
742 if __name__
== "__main__":
745 setup(name
= 'wxPython',
747 description
= DESCRIPTION
,
748 long_description
= LONG_DESCRIPTION
,
750 author_email
= AUTHOR_EMAIL
,
752 download_url
= DOWNLOAD_URL
,
754 platforms
= PLATFORMS
,
755 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
758 packages
= ['wxPython',
760 'wxPython.lib.colourchooser',
761 'wxPython.lib.editor',
762 'wxPython.lib.mixins',
768 'wx.lib.colourchooser',
770 'wx.lib.floatcanvas',
779 extra_path
= EXTRA_PATH
,
781 ext_package
= PKGDIR
,
782 ext_modules
= wxpExtensions
,
784 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
788 data_files
= DATA_FILES
,
791 # Override some of the default distutils command classes with my own
792 cmdclass
= { 'install' : wx_install
,
793 'install_data': wx_smart_install_data
,
794 'install_headers': wx_install_headers
,
795 'clean': wx_extra_clean
,
800 if INSTALL_MULTIVERSION
:
801 setup(name
= 'wxPython-common',
803 description
= DESCRIPTION
,
804 long_description
= LONG_DESCRIPTION
,
806 author_email
= AUTHOR_EMAIL
,
808 download_url
= DOWNLOAD_URL
,
810 platforms
= PLATFORMS
,
811 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
814 package_dir
= { '': 'wxversion' }
,
815 py_modules
= ['wxversion'],
817 data_files
= [('', ['src/wx.pth'])],
819 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
822 cmdclass
= { 'install_data': wx_smart_install_data
,
826 #----------------------------------------------------------------------
827 #----------------------------------------------------------------------