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 wich to be wxPython compatible. The
21 # 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 sys
.setup_is_main
= __name__
== "__main__" # an icky hack!
36 #----------------------------------------------------------------------
37 # Update the packaged config file.
38 #----------------------------------------------------------------------
40 copy_file('config.py', 'wx/build', update
=1, verbose
=1)
41 CLEANUP
.append('wx/build/config.py')
43 #----------------------------------------------------------------------
44 # Update the version file
45 #----------------------------------------------------------------------
47 # The version file is unconditionally updated every time setup.py is
48 # run since the version string can change based on the UNICODE flag
50 open('wx/__version__.py', 'w').write("""\
51 # This file was generated by setup.py...
53 VERSION_STRING = '%(VERSION)s'
54 MAJOR_VERSION = %(VER_MAJOR)s
55 MINOR_VERSION = %(VER_MINOR)s
56 RELEASE_VERSION = %(VER_RELEASE)s
57 SUBREL_VERSION = %(VER_SUBREL)s
59 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
60 SUBREL_VERSION, '%(VER_FLAGS)s')
62 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
65 CLEANUP
.append('wx/__version__.py')
68 #----------------------------------------------------------------------
69 # patch distutils if it can't cope with the "classifiers" or
70 # "download_url" keywords
71 #----------------------------------------------------------------------
73 if sys
.version
< '2.2.3':
74 from distutils
.dist
import DistributionMetadata
75 DistributionMetadata
.classifiers
= None
76 DistributionMetadata
.download_url
= None
79 depends
= {'depends' : depends}
82 #----------------------------------------------------------------------
83 # Define the CORE extension module
84 #----------------------------------------------------------------------
86 msg('Preparing CORE...')
87 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
88 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
95 'src/__core_rename.i',
96 'src/__core_reverse.txt',
116 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
117 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
120 # update the license files
122 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
123 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
124 CLEANUP
.append(opj('licence',file))
125 CLEANUP
.append('licence')
129 build_locale_dir(opj(PKGDIR
, 'locale'))
130 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
134 rc_file
= ['src/wxc.rc']
139 ext
= Extension('_core_', ['src/helpers.cpp',
141 ] + rc_file
+ swig_sources
,
143 include_dirs
= includes
,
144 define_macros
= defines
,
146 library_dirs
= libdirs
,
149 extra_compile_args
= cflags
,
150 extra_link_args
= lflags
,
154 wxpExtensions
.append(ext
)
160 # Extension for the GDI module
161 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
162 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
163 ['src/__gdi_rename.i',
182 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
183 include_dirs
= includes
,
184 define_macros
= defines
,
185 library_dirs
= libdirs
,
187 extra_compile_args
= cflags
,
188 extra_link_args
= lflags
,
191 wxpExtensions
.append(ext
)
198 # Extension for the windows module
199 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
200 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
201 ['src/__windows_rename.i',
202 'src/__windows_reverse.txt',
218 ext
= Extension('_windows_', swig_sources
,
219 include_dirs
= includes
,
220 define_macros
= defines
,
221 library_dirs
= libdirs
,
223 extra_compile_args
= cflags
,
224 extra_link_args
= lflags
,
227 wxpExtensions
.append(ext
)
232 # Extension for the controls module
233 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
234 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
235 [ 'src/__controls_rename.i',
236 'src/__controls_reverse.txt',
260 ext
= Extension('_controls_', swig_sources
,
261 include_dirs
= includes
,
262 define_macros
= defines
,
263 library_dirs
= libdirs
,
265 extra_compile_args
= cflags
,
266 extra_link_args
= lflags
,
269 wxpExtensions
.append(ext
)
274 # Extension for the misc module
275 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
276 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
277 [ 'src/__misc_rename.i',
278 'src/__misc_reverse.txt',
299 ext
= Extension('_misc_', 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 ## Core modules that are not in the "core" namespace start here
316 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
317 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
318 ext
= Extension('_calendar', swig_sources
,
319 include_dirs
= includes
,
320 define_macros
= defines
,
321 library_dirs
= libdirs
,
323 extra_compile_args
= cflags
,
324 extra_link_args
= lflags
,
327 wxpExtensions
.append(ext
)
330 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
331 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
332 ext
= Extension('_grid', swig_sources
,
333 include_dirs
= includes
,
334 define_macros
= defines
,
335 library_dirs
= libdirs
,
337 extra_compile_args
= cflags
,
338 extra_link_args
= lflags
,
341 wxpExtensions
.append(ext
)
345 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
346 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
347 ext
= Extension('_html', swig_sources
,
348 include_dirs
= includes
,
349 define_macros
= defines
,
350 library_dirs
= libdirs
,
352 extra_compile_args
= cflags
,
353 extra_link_args
= lflags
,
356 wxpExtensions
.append(ext
)
360 if not MONOLITHIC
and os
.name
== 'nt':
361 mediaLibs
.append(makeLibName('media')[0])
362 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
363 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
364 ext
= Extension('_media', swig_sources
,
365 include_dirs
= includes
,
366 define_macros
= defines
,
367 library_dirs
= libdirs
,
368 libraries
= mediaLibs
,
369 extra_compile_args
= cflags
,
370 extra_link_args
= lflags
,
373 wxpExtensions
.append(ext
)
376 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
377 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
378 ext
= Extension('_webkit', 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 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
392 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
393 ext
= Extension('_wizard', swig_sources
,
394 include_dirs
= includes
,
395 define_macros
= defines
,
396 library_dirs
= libdirs
,
398 extra_compile_args
= cflags
,
399 extra_link_args
= lflags
,
402 wxpExtensions
.append(ext
)
406 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
407 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
408 [ 'src/_xrc_rename.i',
415 ext
= Extension('_xrc',
418 include_dirs
= includes
+ CONTRIBS_INC
,
419 define_macros
= defines
,
421 library_dirs
= libdirs
,
424 extra_compile_args
= cflags
,
425 extra_link_args
= lflags
,
427 wxpExtensions
.append(ext
)
430 #----------------------------------------------------------------------
431 # Define the GLCanvas extension module
432 #----------------------------------------------------------------------
435 msg('Preparing GLCANVAS...')
436 location
= 'contrib/glcanvas'
438 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
439 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
442 if os
.name
== 'posix':
443 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
444 gl_lflags
= gl_config
.split() + lflags
447 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
450 ext
= Extension('_glcanvas',
453 include_dirs
= includes
+ CONTRIBS_INC
,
454 define_macros
= defines
,
456 library_dirs
= libdirs
,
459 extra_compile_args
= cflags
,
460 extra_link_args
= gl_lflags
,
463 wxpExtensions
.append(ext
)
466 #----------------------------------------------------------------------
467 # Define the OGL extension module
468 #----------------------------------------------------------------------
471 msg('Preparing OGL...')
472 location
= 'contrib/ogl'
474 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
475 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
476 [ '%s/_oglbasic.i' % location
,
477 '%s/_oglshapes.i' % location
,
478 '%s/_oglshapes2.i' % location
,
479 '%s/_oglcanvas.i' % location
,
480 '%s/_ogldefs.i' % location
,
483 ext
= Extension('_ogl',
486 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
487 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
489 library_dirs
= libdirs
,
490 libraries
= libs
+ makeLibName('ogl'),
492 extra_compile_args
= cflags
,
493 extra_link_args
= lflags
,
496 wxpExtensions
.append(ext
)
500 #----------------------------------------------------------------------
501 # Define the STC extension module
502 #----------------------------------------------------------------------
505 msg('Preparing STC...')
506 location
= 'contrib/stc'
508 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
510 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
512 ## NOTE: need to add something like this to the stc.bkl...
514 ## # Check if gen_iface needs to be run for the wxSTC sources
515 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
516 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
517 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
519 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
521 ## os.chdir(opj(CTRB_SRC, 'stc'))
522 ## sys.path.insert(0, os.curdir)
524 ## gen_iface.main([])
528 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
529 USE_SWIG
, swig_force
,
530 swig_args
+ ['-I'+STC_H
, '-I'+location
],
531 [opj(STC_H
, 'stc.h')] + swig_deps
)
533 ext
= Extension('_stc',
536 include_dirs
= includes
+ CONTRIBS_INC
,
537 define_macros
= defines
,
539 library_dirs
= libdirs
,
540 libraries
= libs
+ makeLibName('stc'),
542 extra_compile_args
= cflags
,
543 extra_link_args
= lflags
,
546 wxpExtensions
.append(ext
)
550 #----------------------------------------------------------------------
551 # Define the IEWIN extension module (experimental)
552 #----------------------------------------------------------------------
555 msg('Preparing IEWIN...')
556 location
= 'contrib/iewin'
558 swig_files
= ['iewin.i', ]
560 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
561 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
564 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
565 '%s/wxactivex.cpp' % location
,
568 include_dirs
= includes
+ CONTRIBS_INC
,
569 define_macros
= defines
,
571 library_dirs
= libdirs
,
574 extra_compile_args
= cflags
,
575 extra_link_args
= lflags
,
578 wxpExtensions
.append(ext
)
581 #----------------------------------------------------------------------
582 # Define the ACTIVEX extension module (experimental)
583 #----------------------------------------------------------------------
586 msg('Preparing ACTIVEX...')
587 location
= 'contrib/activex'
588 axloc
= opj(location
, "wxie")
590 swig_files
= ['activex.i', ]
592 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
593 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
594 [ '%s/_activex_ex.py' % location
])
597 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
598 '%s/wxactivex.cpp' % axloc
,
601 include_dirs
= includes
+ [ axloc
],
602 define_macros
= defines
,
604 library_dirs
= libdirs
,
607 extra_compile_args
= cflags
,
608 extra_link_args
= lflags
,
611 wxpExtensions
.append(ext
)
614 #----------------------------------------------------------------------
615 # Define the GIZMOS extension module
616 #----------------------------------------------------------------------
619 msg('Preparing GIZMOS...')
620 location
= 'contrib/gizmos'
622 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
623 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
625 ext
= Extension('_gizmos',
626 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
628 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
629 define_macros
= defines
,
631 library_dirs
= libdirs
,
632 libraries
= libs
+ makeLibName('gizmos'),
634 extra_compile_args
= cflags
,
635 extra_link_args
= lflags
,
638 wxpExtensions
.append(ext
)
642 #----------------------------------------------------------------------
643 # Define the DLLWIDGET extension module
644 #----------------------------------------------------------------------
647 msg('Preparing DLLWIDGET...')
648 location
= 'contrib/dllwidget'
649 swig_files
= ['dllwidget_.i']
651 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
652 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
654 # copy a contrib project specific py module to the main package dir
655 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
656 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
658 ext
= Extension('dllwidget_c', [
659 '%s/dllwidget.cpp' % location
,
662 include_dirs
= includes
+ CONTRIBS_INC
,
663 define_macros
= defines
,
665 library_dirs
= libdirs
,
668 extra_compile_args
= cflags
,
669 extra_link_args
= lflags
,
672 wxpExtensions
.append(ext
)
677 #----------------------------------------------------------------------
678 # Tools, scripts data files, etc.
679 #----------------------------------------------------------------------
684 SCRIPTS
= [opj('scripts/helpviewer'),
685 opj('scripts/img2png'),
686 opj('scripts/img2py'),
687 opj('scripts/img2xpm'),
688 opj('scripts/pyalacarte'),
689 opj('scripts/pyalamode'),
690 opj('scripts/pycrust'),
691 opj('scripts/pyshell'),
692 opj('scripts/pywrap'),
693 opj('scripts/pywrap'),
694 opj('scripts/pywxrc'),
695 opj('scripts/xrced'),
700 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
701 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
702 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
708 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
709 i_files
= glob
.glob(opj("src/*.i")) + \
710 glob
.glob(opj("src/_*.py")) + \
711 glob
.glob(opj("src/*.swg"))
713 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
714 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
718 if INSTALL_MULTIVERSION
:
719 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
)
720 open("src/wx.pth", "w").write(EXTRA_PATH
)
721 CLEANUP
.append("src/wx.pth")
727 #----------------------------------------------------------------------
728 # Do the Setup/Build/Install/Whatever
729 #----------------------------------------------------------------------
731 if __name__
== "__main__":
734 setup(name
= 'wxPython',
736 description
= DESCRIPTION
,
737 long_description
= LONG_DESCRIPTION
,
739 author_email
= AUTHOR_EMAIL
,
741 download_url
= DOWNLOAD_URL
,
743 platforms
= PLATFORMS
,
744 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
747 packages
= ['wxPython',
749 'wxPython.lib.colourchooser',
750 'wxPython.lib.editor',
751 'wxPython.lib.mixins',
757 'wx.lib.colourchooser',
759 'wx.lib.floatcanvas',
768 extra_path
= EXTRA_PATH
,
770 ext_package
= PKGDIR
,
771 ext_modules
= wxpExtensions
,
773 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
777 data_files
= DATA_FILES
,
780 # Override some of the default distutils command classes with my own
781 cmdclass
= { 'install' : wx_install
,
782 'install_data': wx_smart_install_data
,
783 'install_headers': wx_install_headers
,
784 'clean': wx_extra_clean
,
789 if INSTALL_MULTIVERSION
:
790 setup(name
= 'wxPython-common',
792 description
= DESCRIPTION
,
793 long_description
= LONG_DESCRIPTION
,
795 author_email
= AUTHOR_EMAIL
,
797 download_url
= DOWNLOAD_URL
,
799 platforms
= PLATFORMS
,
800 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
803 package_dir
= { '': 'wxversion' }
,
804 py_modules
= ['wxversion'],
806 data_files
= [('', ['src/wx.pth'])],
808 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
811 cmdclass
= { 'install_data': wx_smart_install_data
,
815 #----------------------------------------------------------------------
816 #----------------------------------------------------------------------