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 #----------------------------------------------------------------------
85 # It may come on either stdout or stderr, depending on the
86 # version, so read both.
87 i
, o
, e
= os
.popen3(SWIG
+ ' -version', 't')
88 stext
= o
.read() + e
.read()
90 match
= re
.search(r
'[0-9]+\.[0-9]+\.[0-9]+$', stext
, re
.MULTILINE
)
94 open('include/wx/wxPython/swigver.h', 'w').write('''\
95 // This file was generated by setup.py
97 #define wxPy_SWIG_VERSION "SWIG-%s"
99 msg('Using SWIG-' + SVER
)
102 msg('\nUnable to get SWIG version number\n')
105 #----------------------------------------------------------------------
106 # patch distutils if it can't cope with the "classifiers" or
107 # "download_url" keywords
108 #----------------------------------------------------------------------
110 if sys
.version
< '2.2.3':
111 from distutils
.dist
import DistributionMetadata
112 DistributionMetadata
.classifiers
= None
113 DistributionMetadata
.download_url
= None
116 depends
= {'depends' : depends}
119 #----------------------------------------------------------------------
120 # Define the CORE extension module
121 #----------------------------------------------------------------------
123 msg('Preparing CORE...')
124 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
125 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
129 'src/_constraints.i',
132 'src/__core_rename.i',
133 'src/__core_reverse.txt',
154 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
155 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
158 # update the license files
160 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
161 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
162 CLEANUP
.append(opj('licence',file))
163 CLEANUP
.append('licence')
167 build_locale_dir(opj(PKGDIR
, 'locale'))
168 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
172 rc_file
= ['src/wxc.rc']
177 ext
= Extension('_core_', ['src/helpers.cpp',
178 ] + rc_file
+ swig_sources
,
180 include_dirs
= includes
,
181 define_macros
= defines
,
183 library_dirs
= libdirs
,
186 extra_compile_args
= cflags
,
187 extra_link_args
= lflags
,
191 wxpExtensions
.append(ext
)
197 # Extension for the GDI module
198 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
199 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
200 ['src/__gdi_rename.i',
220 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
221 include_dirs
= includes
,
222 define_macros
= defines
,
223 library_dirs
= libdirs
,
225 extra_compile_args
= cflags
,
226 extra_link_args
= lflags
,
229 wxpExtensions
.append(ext
)
236 # Extension for the windows module
237 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
238 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
239 ['src/__windows_rename.i',
240 'src/__windows_reverse.txt',
256 ext
= Extension('_windows_', swig_sources
,
257 include_dirs
= includes
,
258 define_macros
= defines
,
259 library_dirs
= libdirs
,
261 extra_compile_args
= cflags
,
262 extra_link_args
= lflags
,
265 wxpExtensions
.append(ext
)
270 # Extension for the controls module
271 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
272 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
273 [ 'src/__controls_rename.i',
274 'src/__controls_reverse.txt',
299 ext
= Extension('_controls_', swig_sources
,
300 include_dirs
= includes
,
301 define_macros
= defines
,
302 library_dirs
= libdirs
,
304 extra_compile_args
= cflags
,
305 extra_link_args
= lflags
,
308 wxpExtensions
.append(ext
)
313 # Extension for the misc module
314 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
315 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
316 [ 'src/__misc_rename.i',
317 'src/__misc_reverse.txt',
338 ext
= Extension('_misc_', swig_sources
,
339 include_dirs
= includes
,
340 define_macros
= defines
,
341 library_dirs
= libdirs
,
343 extra_compile_args
= cflags
,
344 extra_link_args
= lflags
,
347 wxpExtensions
.append(ext
)
352 ## Core modules that are not in the "core" namespace start here
355 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
356 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
357 ext
= Extension('_calendar', swig_sources
,
358 include_dirs
= includes
,
359 define_macros
= defines
,
360 library_dirs
= libdirs
,
362 extra_compile_args
= cflags
,
363 extra_link_args
= lflags
,
366 wxpExtensions
.append(ext
)
369 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
370 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
371 ext
= Extension('_grid', swig_sources
,
372 include_dirs
= includes
,
373 define_macros
= defines
,
374 library_dirs
= libdirs
,
376 extra_compile_args
= cflags
,
377 extra_link_args
= lflags
,
380 wxpExtensions
.append(ext
)
384 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
385 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
386 ext
= Extension('_html', swig_sources
,
387 include_dirs
= includes
,
388 define_macros
= defines
,
389 library_dirs
= libdirs
,
391 extra_compile_args
= cflags
,
392 extra_link_args
= lflags
,
395 wxpExtensions
.append(ext
)
399 if not MONOLITHIC
and os
.name
== 'nt':
400 mediaLibs
.append(makeLibName('media')[0])
401 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
402 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
403 ext
= Extension('_media', swig_sources
,
404 include_dirs
= includes
,
405 define_macros
= defines
,
406 library_dirs
= libdirs
,
407 libraries
= mediaLibs
,
408 extra_compile_args
= cflags
,
409 extra_link_args
= lflags
,
412 wxpExtensions
.append(ext
)
415 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
416 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
417 ext
= Extension('_webkit', swig_sources
,
418 include_dirs
= includes
,
419 define_macros
= defines
,
420 library_dirs
= libdirs
,
422 extra_compile_args
= cflags
,
423 extra_link_args
= lflags
,
426 wxpExtensions
.append(ext
)
430 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
431 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
432 ext
= Extension('_wizard', swig_sources
,
433 include_dirs
= includes
,
434 define_macros
= defines
,
435 library_dirs
= libdirs
,
437 extra_compile_args
= cflags
,
438 extra_link_args
= lflags
,
441 wxpExtensions
.append(ext
)
445 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
446 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
447 [ 'src/_xrc_rename.i',
454 ext
= Extension('_xrc',
457 include_dirs
= includes
+ CONTRIBS_INC
,
458 define_macros
= defines
,
460 library_dirs
= libdirs
,
463 extra_compile_args
= cflags
,
464 extra_link_args
= lflags
,
466 wxpExtensions
.append(ext
)
469 #----------------------------------------------------------------------
470 # Define the GLCanvas extension module
471 #----------------------------------------------------------------------
474 msg('Preparing GLCANVAS...')
475 location
= 'contrib/glcanvas'
477 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
478 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
481 if os
.name
== 'posix':
482 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
483 gl_lflags
= gl_config
.split() + lflags
486 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
489 ext
= Extension('_glcanvas',
492 include_dirs
= includes
+ CONTRIBS_INC
,
493 define_macros
= defines
,
495 library_dirs
= libdirs
,
498 extra_compile_args
= cflags
,
499 extra_link_args
= gl_lflags
,
502 wxpExtensions
.append(ext
)
505 #----------------------------------------------------------------------
506 # Define the OGL extension module
507 #----------------------------------------------------------------------
510 msg('Preparing OGL...')
511 location
= 'contrib/ogl'
513 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
514 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
515 [ '%s/_oglbasic.i' % location
,
516 '%s/_oglshapes.i' % location
,
517 '%s/_oglshapes2.i' % location
,
518 '%s/_oglcanvas.i' % location
,
519 '%s/_ogldefs.i' % location
,
522 ext
= Extension('_ogl',
525 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
526 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
528 library_dirs
= libdirs
,
529 libraries
= libs
+ makeLibName('ogl'),
531 extra_compile_args
= cflags
,
532 extra_link_args
= lflags
,
535 wxpExtensions
.append(ext
)
539 #----------------------------------------------------------------------
540 # Define the STC extension module
541 #----------------------------------------------------------------------
544 msg('Preparing STC...')
545 location
= 'contrib/stc'
547 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
549 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
551 ## NOTE: need to add something like this to the stc.bkl...
553 ## # Check if gen_iface needs to be run for the wxSTC sources
554 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
555 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
556 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
558 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
560 ## os.chdir(opj(CTRB_SRC, 'stc'))
561 ## sys.path.insert(0, os.curdir)
563 ## gen_iface.main([])
567 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
568 USE_SWIG
, swig_force
,
569 swig_args
+ ['-I'+STC_H
, '-I'+location
],
570 [opj(STC_H
, 'stc.h'),
571 opj(location
, "_stc_utf8_methods.py"),
572 opj(location
, "_stc_docstrings.i"),
573 opj(location
, "_stc_gendocs.i"),
576 ext
= Extension('_stc',
579 include_dirs
= includes
+ CONTRIBS_INC
,
580 define_macros
= defines
,
582 library_dirs
= libdirs
,
583 libraries
= libs
+ makeLibName('stc'),
585 extra_compile_args
= cflags
,
586 extra_link_args
= lflags
,
589 wxpExtensions
.append(ext
)
592 #----------------------------------------------------------------------
593 # Define the ACTIVEX extension module (experimental)
594 #----------------------------------------------------------------------
597 msg('Preparing ACTIVEX...')
598 location
= 'contrib/activex'
599 axloc
= opj(location
, "wxie")
601 swig_files
= ['activex.i', ]
603 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
604 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
605 [ '%s/_activex_ex.py' % location
])
608 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
609 '%s/wxactivex.cpp' % axloc
,
612 include_dirs
= includes
+ [ axloc
],
613 define_macros
= defines
,
615 library_dirs
= libdirs
,
618 extra_compile_args
= cflags
,
619 extra_link_args
= lflags
,
622 wxpExtensions
.append(ext
)
625 #----------------------------------------------------------------------
626 # Define the GIZMOS extension module
627 #----------------------------------------------------------------------
630 msg('Preparing GIZMOS...')
631 location
= 'contrib/gizmos'
633 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
634 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
636 ext
= Extension('_gizmos',
637 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
639 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
640 define_macros
= defines
,
642 library_dirs
= libdirs
,
643 libraries
= libs
+ makeLibName('gizmos'),
645 extra_compile_args
= cflags
,
646 extra_link_args
= lflags
,
649 wxpExtensions
.append(ext
)
652 #----------------------------------------------------------------------
653 # Define the ANIMATE extension module
654 #----------------------------------------------------------------------
657 msg('Preparing ANIMATE...')
658 location
= 'contrib/animate'
660 swig_sources
= run_swig(['animate.i'], location
, GENDIR
, PKGDIR
,
661 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
663 ext
= Extension('_animate',
666 include_dirs
= includes
+ CONTRIBS_INC
,
667 define_macros
= defines
,
669 library_dirs
= libdirs
,
670 libraries
= libs
+ makeLibName('animate'),
672 extra_compile_args
= cflags
,
673 extra_link_args
= lflags
,
676 wxpExtensions
.append(ext
)
680 #----------------------------------------------------------------------
681 # Define the DLLWIDGET extension module
682 #----------------------------------------------------------------------
685 msg('Preparing DLLWIDGET...')
686 location
= 'contrib/dllwidget'
687 swig_files
= ['dllwidget_.i']
689 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
690 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
692 # copy a contrib project specific py module to the main package dir
693 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
694 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
696 ext
= Extension('dllwidget_c', [
697 '%s/dllwidget.cpp' % location
,
700 include_dirs
= includes
+ CONTRIBS_INC
,
701 define_macros
= defines
,
703 library_dirs
= libdirs
,
706 extra_compile_args
= cflags
,
707 extra_link_args
= lflags
,
710 wxpExtensions
.append(ext
)
715 #----------------------------------------------------------------------
716 # Tools, scripts data files, etc.
717 #----------------------------------------------------------------------
722 SCRIPTS
= [opj('scripts/helpviewer'),
723 opj('scripts/img2png'),
724 opj('scripts/img2py'),
725 opj('scripts/img2xpm'),
726 opj('scripts/pyalacarte'),
727 opj('scripts/pyalamode'),
728 opj('scripts/pycrust'),
729 opj('scripts/pyshell'),
730 opj('scripts/pywrap'),
731 opj('scripts/pywrap'),
732 opj('scripts/pywxrc'),
733 opj('scripts/xrced'),
738 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
739 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
740 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
746 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
747 i_files
= glob
.glob(opj("src/*.i")) + \
748 glob
.glob(opj("src/_*.py")) + \
749 glob
.glob(opj("src/*.swg"))
751 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
752 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
756 if INSTALL_MULTIVERSION
:
757 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
, shortVer
=not EP_FULL_VER
)
758 open("src/wx.pth", "w").write(EXTRA_PATH
)
759 CLEANUP
.append("src/wx.pth")
765 #----------------------------------------------------------------------
766 # Do the Setup/Build/Install/Whatever
767 #----------------------------------------------------------------------
769 if __name__
== "__main__":
772 setup(name
= 'wxPython',
774 description
= DESCRIPTION
,
775 long_description
= LONG_DESCRIPTION
,
777 author_email
= AUTHOR_EMAIL
,
779 download_url
= DOWNLOAD_URL
,
781 platforms
= PLATFORMS
,
782 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
785 packages
= ['wxPython',
787 'wxPython.lib.colourchooser',
788 'wxPython.lib.editor',
789 'wxPython.lib.mixins',
795 'wx.lib.colourchooser',
797 'wx.lib.floatcanvas',
806 extra_path
= EXTRA_PATH
,
808 ext_package
= PKGDIR
,
809 ext_modules
= wxpExtensions
,
811 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
815 data_files
= DATA_FILES
,
818 # Override some of the default distutils command classes with my own
819 cmdclass
= { 'install' : wx_install
,
820 'install_data': wx_smart_install_data
,
821 'install_headers': wx_install_headers
,
822 'clean': wx_extra_clean
,
827 if INSTALL_MULTIVERSION
:
828 setup(name
= 'wxPython-common',
830 description
= DESCRIPTION
,
831 long_description
= LONG_DESCRIPTION
,
833 author_email
= AUTHOR_EMAIL
,
835 download_url
= DOWNLOAD_URL
,
837 platforms
= PLATFORMS
,
838 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
841 package_dir
= { '': 'wxversion' }
,
842 py_modules
= ['wxversion'],
844 data_files
= [('', ['src/wx.pth'])],
846 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
849 cmdclass
= { 'install_data': wx_smart_install_data
,
853 #----------------------------------------------------------------------
854 #----------------------------------------------------------------------