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',
128 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
129 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
132 # update the license files
134 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
135 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
136 CLEANUP
.append(opj('licence',file))
137 CLEANUP
.append('licence')
141 build_locale_dir(opj(PKGDIR
, 'locale'))
142 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
146 rc_file
= ['src/wxc.rc']
151 ext
= Extension('_core_', ['src/helpers.cpp',
152 ] + rc_file
+ swig_sources
,
154 include_dirs
= includes
,
155 define_macros
= defines
,
157 library_dirs
= libdirs
,
160 extra_compile_args
= cflags
,
161 extra_link_args
= lflags
,
165 wxpExtensions
.append(ext
)
171 # Extension for the GDI module
172 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
173 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
174 ['src/__gdi_rename.i',
194 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
195 include_dirs
= includes
,
196 define_macros
= defines
,
197 library_dirs
= libdirs
,
199 extra_compile_args
= cflags
,
200 extra_link_args
= lflags
,
203 wxpExtensions
.append(ext
)
210 # Extension for the windows module
211 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
212 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
213 ['src/__windows_rename.i',
214 'src/__windows_reverse.txt',
230 ext
= Extension('_windows_', swig_sources
,
231 include_dirs
= includes
,
232 define_macros
= defines
,
233 library_dirs
= libdirs
,
235 extra_compile_args
= cflags
,
236 extra_link_args
= lflags
,
239 wxpExtensions
.append(ext
)
244 # Extension for the controls module
245 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
246 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
247 [ 'src/__controls_rename.i',
248 'src/__controls_reverse.txt',
273 ext
= Extension('_controls_', swig_sources
,
274 include_dirs
= includes
,
275 define_macros
= defines
,
276 library_dirs
= libdirs
,
278 extra_compile_args
= cflags
,
279 extra_link_args
= lflags
,
282 wxpExtensions
.append(ext
)
287 # Extension for the misc module
288 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
289 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
290 [ 'src/__misc_rename.i',
291 'src/__misc_reverse.txt',
312 ext
= Extension('_misc_', swig_sources
,
313 include_dirs
= includes
,
314 define_macros
= defines
,
315 library_dirs
= libdirs
,
317 extra_compile_args
= cflags
,
318 extra_link_args
= lflags
,
321 wxpExtensions
.append(ext
)
326 ## Core modules that are not in the "core" namespace start here
329 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
330 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
331 ext
= Extension('_calendar', swig_sources
,
332 include_dirs
= includes
,
333 define_macros
= defines
,
334 library_dirs
= libdirs
,
336 extra_compile_args
= cflags
,
337 extra_link_args
= lflags
,
340 wxpExtensions
.append(ext
)
343 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
344 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
345 ext
= Extension('_grid', swig_sources
,
346 include_dirs
= includes
,
347 define_macros
= defines
,
348 library_dirs
= libdirs
,
350 extra_compile_args
= cflags
,
351 extra_link_args
= lflags
,
354 wxpExtensions
.append(ext
)
358 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
359 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
360 ext
= Extension('_html', swig_sources
,
361 include_dirs
= includes
,
362 define_macros
= defines
,
363 library_dirs
= libdirs
,
365 extra_compile_args
= cflags
,
366 extra_link_args
= lflags
,
369 wxpExtensions
.append(ext
)
373 if not MONOLITHIC
and os
.name
== 'nt':
374 mediaLibs
.append(makeLibName('media')[0])
375 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
376 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
377 ext
= Extension('_media', swig_sources
,
378 include_dirs
= includes
,
379 define_macros
= defines
,
380 library_dirs
= libdirs
,
381 libraries
= mediaLibs
,
382 extra_compile_args
= cflags
,
383 extra_link_args
= lflags
,
386 wxpExtensions
.append(ext
)
389 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
390 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
391 ext
= Extension('_webkit', swig_sources
,
392 include_dirs
= includes
,
393 define_macros
= defines
,
394 library_dirs
= libdirs
,
396 extra_compile_args
= cflags
,
397 extra_link_args
= lflags
,
400 wxpExtensions
.append(ext
)
404 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
405 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
406 ext
= Extension('_wizard', swig_sources
,
407 include_dirs
= includes
,
408 define_macros
= defines
,
409 library_dirs
= libdirs
,
411 extra_compile_args
= cflags
,
412 extra_link_args
= lflags
,
415 wxpExtensions
.append(ext
)
419 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
420 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
421 [ 'src/_xrc_rename.i',
428 ext
= Extension('_xrc',
431 include_dirs
= includes
+ CONTRIBS_INC
,
432 define_macros
= defines
,
434 library_dirs
= libdirs
,
437 extra_compile_args
= cflags
,
438 extra_link_args
= lflags
,
440 wxpExtensions
.append(ext
)
443 #----------------------------------------------------------------------
444 # Define the GLCanvas extension module
445 #----------------------------------------------------------------------
448 msg('Preparing GLCANVAS...')
449 location
= 'contrib/glcanvas'
451 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
452 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
455 if os
.name
== 'posix':
456 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
457 gl_lflags
= gl_config
.split() + lflags
460 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
463 ext
= Extension('_glcanvas',
466 include_dirs
= includes
+ CONTRIBS_INC
,
467 define_macros
= defines
,
469 library_dirs
= libdirs
,
472 extra_compile_args
= cflags
,
473 extra_link_args
= gl_lflags
,
476 wxpExtensions
.append(ext
)
479 #----------------------------------------------------------------------
480 # Define the OGL extension module
481 #----------------------------------------------------------------------
484 msg('Preparing OGL...')
485 location
= 'contrib/ogl'
487 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
488 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
489 [ '%s/_oglbasic.i' % location
,
490 '%s/_oglshapes.i' % location
,
491 '%s/_oglshapes2.i' % location
,
492 '%s/_oglcanvas.i' % location
,
493 '%s/_ogldefs.i' % location
,
496 ext
= Extension('_ogl',
499 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
500 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
502 library_dirs
= libdirs
,
503 libraries
= libs
+ makeLibName('ogl'),
505 extra_compile_args
= cflags
,
506 extra_link_args
= lflags
,
509 wxpExtensions
.append(ext
)
513 #----------------------------------------------------------------------
514 # Define the STC extension module
515 #----------------------------------------------------------------------
518 msg('Preparing STC...')
519 location
= 'contrib/stc'
521 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
523 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
525 ## NOTE: need to add something like this to the stc.bkl...
527 ## # Check if gen_iface needs to be run for the wxSTC sources
528 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
529 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
530 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
532 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
534 ## os.chdir(opj(CTRB_SRC, 'stc'))
535 ## sys.path.insert(0, os.curdir)
537 ## gen_iface.main([])
541 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
542 USE_SWIG
, swig_force
,
543 swig_args
+ ['-I'+STC_H
, '-I'+location
],
544 [opj(STC_H
, 'stc.h'),
545 opj(location
, "_stc_utf8_methods.py"),
546 opj(location
, "_stc_docstrings.i"),
547 opj(location
, "_stc_gendocs.i"),
550 ext
= Extension('_stc',
553 include_dirs
= includes
+ CONTRIBS_INC
,
554 define_macros
= defines
,
556 library_dirs
= libdirs
,
557 libraries
= libs
+ makeLibName('stc'),
559 extra_compile_args
= cflags
,
560 extra_link_args
= lflags
,
563 wxpExtensions
.append(ext
)
566 #----------------------------------------------------------------------
567 # Define the ACTIVEX extension module (experimental)
568 #----------------------------------------------------------------------
571 msg('Preparing ACTIVEX...')
572 location
= 'contrib/activex'
573 axloc
= opj(location
, "wxie")
575 swig_files
= ['activex.i', ]
577 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
578 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
579 [ '%s/_activex_ex.py' % location
])
582 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
583 '%s/wxactivex.cpp' % axloc
,
586 include_dirs
= includes
+ [ axloc
],
587 define_macros
= defines
,
589 library_dirs
= libdirs
,
592 extra_compile_args
= cflags
,
593 extra_link_args
= lflags
,
596 wxpExtensions
.append(ext
)
599 #----------------------------------------------------------------------
600 # Define the GIZMOS extension module
601 #----------------------------------------------------------------------
604 msg('Preparing GIZMOS...')
605 location
= 'contrib/gizmos'
607 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
608 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
610 ext
= Extension('_gizmos',
611 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
613 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
614 define_macros
= defines
,
616 library_dirs
= libdirs
,
617 libraries
= libs
+ makeLibName('gizmos'),
619 extra_compile_args
= cflags
,
620 extra_link_args
= lflags
,
623 wxpExtensions
.append(ext
)
626 #----------------------------------------------------------------------
627 # Define the ANIMATE extension module
628 #----------------------------------------------------------------------
631 msg('Preparing ANIMATE...')
632 location
= 'contrib/animate'
634 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
635 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
637 ext
= Extension('_animate',
640 include_dirs
= includes
+ CONTRIBS_INC
,
641 define_macros
= defines
,
643 library_dirs
= libdirs
,
644 libraries
= libs
+ makeLibName('animate'),
646 extra_compile_args
= cflags
,
647 extra_link_args
= lflags
,
650 wxpExtensions
.append(ext
)
654 #----------------------------------------------------------------------
655 # Define the DLLWIDGET extension module
656 #----------------------------------------------------------------------
659 msg('Preparing DLLWIDGET...')
660 location
= 'contrib/dllwidget'
661 swig_files
= ['dllwidget_.i']
663 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
664 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
666 # copy a contrib project specific py module to the main package dir
667 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
668 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
670 ext
= Extension('dllwidget_c', [
671 '%s/dllwidget.cpp' % location
,
674 include_dirs
= includes
+ CONTRIBS_INC
,
675 define_macros
= defines
,
677 library_dirs
= libdirs
,
680 extra_compile_args
= cflags
,
681 extra_link_args
= lflags
,
684 wxpExtensions
.append(ext
)
689 #----------------------------------------------------------------------
690 # Tools, scripts data files, etc.
691 #----------------------------------------------------------------------
696 SCRIPTS
= [opj('scripts/helpviewer'),
697 opj('scripts/img2png'),
698 opj('scripts/img2py'),
699 opj('scripts/img2xpm'),
700 opj('scripts/pyalacarte'),
701 opj('scripts/pyalamode'),
702 opj('scripts/pycrust'),
703 opj('scripts/pyshell'),
704 opj('scripts/pywrap'),
705 opj('scripts/pywrap'),
706 opj('scripts/pywxrc'),
707 opj('scripts/xrced'),
712 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
713 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
714 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
720 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
721 i_files
= glob
.glob(opj("src/*.i")) + \
722 glob
.glob(opj("src/_*.py")) + \
723 glob
.glob(opj("src/*.swg"))
725 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
726 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
730 if INSTALL_MULTIVERSION
:
731 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
732 open("src/wx.pth", "w").write(EXTRA_PATH
)
733 CLEANUP
.append("src/wx.pth")
739 #----------------------------------------------------------------------
740 # Do the Setup/Build/Install/Whatever
741 #----------------------------------------------------------------------
743 if __name__
== "__main__":
746 setup(name
= 'wxPython',
748 description
= DESCRIPTION
,
749 long_description
= LONG_DESCRIPTION
,
751 author_email
= AUTHOR_EMAIL
,
753 download_url
= DOWNLOAD_URL
,
755 platforms
= PLATFORMS
,
756 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
759 packages
= ['wxPython',
761 'wxPython.lib.colourchooser',
762 'wxPython.lib.editor',
763 'wxPython.lib.mixins',
769 'wx.lib.colourchooser',
771 'wx.lib.floatcanvas',
780 extra_path
= EXTRA_PATH
,
782 ext_package
= PKGDIR
,
783 ext_modules
= wxpExtensions
,
785 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
789 data_files
= DATA_FILES
,
792 # Override some of the default distutils command classes with my own
793 cmdclass
= { 'install' : wx_install
,
794 'install_data': wx_smart_install_data
,
795 'install_headers': wx_install_headers
,
796 'clean': wx_extra_clean
,
801 if INSTALL_MULTIVERSION
:
802 setup(name
= 'wxPython-common',
804 description
= DESCRIPTION
,
805 long_description
= LONG_DESCRIPTION
,
807 author_email
= AUTHOR_EMAIL
,
809 download_url
= DOWNLOAD_URL
,
811 platforms
= PLATFORMS
,
812 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
815 package_dir
= { '': 'wxversion' }
,
816 py_modules
= ['wxversion'],
818 data_files
= [('', ['src/wx.pth'])],
820 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
823 cmdclass
= { 'install_data': wx_smart_install_data
,
827 #----------------------------------------------------------------------
828 #----------------------------------------------------------------------