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',
298 ext
= Extension('_misc_', swig_sources
,
299 include_dirs
= includes
,
300 define_macros
= defines
,
301 library_dirs
= libdirs
,
303 extra_compile_args
= cflags
,
304 extra_link_args
= lflags
,
307 wxpExtensions
.append(ext
)
312 ## Core modules that are not in the "core" namespace start here
315 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
316 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
317 ext
= Extension('_calendar', swig_sources
,
318 include_dirs
= includes
,
319 define_macros
= defines
,
320 library_dirs
= libdirs
,
322 extra_compile_args
= cflags
,
323 extra_link_args
= lflags
,
326 wxpExtensions
.append(ext
)
329 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
330 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
331 ext
= Extension('_grid', 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
)
344 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
345 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
346 ext
= Extension('_html', swig_sources
,
347 include_dirs
= includes
,
348 define_macros
= defines
,
349 library_dirs
= libdirs
,
351 extra_compile_args
= cflags
,
352 extra_link_args
= lflags
,
355 wxpExtensions
.append(ext
)
359 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
360 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
361 ext
= Extension('_webkit', swig_sources
,
362 include_dirs
= includes
,
363 define_macros
= defines
,
364 library_dirs
= libdirs
,
366 extra_compile_args
= cflags
,
367 extra_link_args
= lflags
,
370 wxpExtensions
.append(ext
)
374 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
375 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
376 ext
= Extension('_wizard', swig_sources
,
377 include_dirs
= includes
,
378 define_macros
= defines
,
379 library_dirs
= libdirs
,
381 extra_compile_args
= cflags
,
382 extra_link_args
= lflags
,
385 wxpExtensions
.append(ext
)
389 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
390 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
391 [ 'src/_xrc_rename.i',
398 ext
= Extension('_xrc',
401 include_dirs
= includes
+ CONTRIBS_INC
,
402 define_macros
= defines
,
404 library_dirs
= libdirs
,
407 extra_compile_args
= cflags
,
408 extra_link_args
= lflags
,
410 wxpExtensions
.append(ext
)
413 #----------------------------------------------------------------------
414 # Define the GLCanvas extension module
415 #----------------------------------------------------------------------
418 msg('Preparing GLCANVAS...')
419 location
= 'contrib/glcanvas'
421 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
422 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
425 if os
.name
== 'posix':
426 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
427 gl_lflags
= gl_config
.split() + lflags
430 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
433 ext
= Extension('_glcanvas',
436 include_dirs
= includes
+ CONTRIBS_INC
,
437 define_macros
= defines
,
439 library_dirs
= libdirs
,
442 extra_compile_args
= cflags
,
443 extra_link_args
= gl_lflags
,
446 wxpExtensions
.append(ext
)
449 #----------------------------------------------------------------------
450 # Define the OGL extension module
451 #----------------------------------------------------------------------
454 msg('Preparing OGL...')
455 location
= 'contrib/ogl'
457 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
458 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
459 [ '%s/_oglbasic.i' % location
,
460 '%s/_oglshapes.i' % location
,
461 '%s/_oglshapes2.i' % location
,
462 '%s/_oglcanvas.i' % location
,
463 '%s/_ogldefs.i' % location
,
466 ext
= Extension('_ogl',
469 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
470 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
472 library_dirs
= libdirs
,
473 libraries
= libs
+ makeLibName('ogl'),
475 extra_compile_args
= cflags
,
476 extra_link_args
= lflags
,
479 wxpExtensions
.append(ext
)
483 #----------------------------------------------------------------------
484 # Define the STC extension module
485 #----------------------------------------------------------------------
488 msg('Preparing STC...')
489 location
= 'contrib/stc'
491 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
493 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
495 ## NOTE: need to add something like this to the stc.bkl...
497 ## # Check if gen_iface needs to be run for the wxSTC sources
498 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
499 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
500 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
502 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
504 ## os.chdir(opj(CTRB_SRC, 'stc'))
505 ## sys.path.insert(0, os.curdir)
507 ## gen_iface.main([])
511 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
512 USE_SWIG
, swig_force
,
513 swig_args
+ ['-I'+STC_H
, '-I'+location
],
514 [opj(STC_H
, 'stc.h')] + swig_deps
)
516 ext
= Extension('_stc',
519 include_dirs
= includes
+ CONTRIBS_INC
,
520 define_macros
= defines
,
522 library_dirs
= libdirs
,
523 libraries
= libs
+ makeLibName('stc'),
525 extra_compile_args
= cflags
,
526 extra_link_args
= lflags
,
529 wxpExtensions
.append(ext
)
533 #----------------------------------------------------------------------
534 # Define the IEWIN extension module (experimental)
535 #----------------------------------------------------------------------
538 msg('Preparing IEWIN...')
539 location
= 'contrib/iewin'
541 swig_files
= ['iewin.i', ]
543 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
544 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
547 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
548 '%s/wxactivex.cpp' % location
,
551 include_dirs
= includes
+ CONTRIBS_INC
,
552 define_macros
= defines
,
554 library_dirs
= libdirs
,
557 extra_compile_args
= cflags
,
558 extra_link_args
= lflags
,
561 wxpExtensions
.append(ext
)
564 #----------------------------------------------------------------------
565 # Define the ACTIVEX extension module (experimental)
566 #----------------------------------------------------------------------
569 msg('Preparing ACTIVEX...')
570 location
= 'contrib/activex'
571 axloc
= opj(location
, "wxie")
573 swig_files
= ['activex.i', ]
575 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
576 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
577 [ '%s/_activex_ex.py' % location
])
580 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
581 '%s/wxactivex.cpp' % axloc
,
584 include_dirs
= includes
+ [ axloc
],
585 define_macros
= defines
,
587 library_dirs
= libdirs
,
590 extra_compile_args
= cflags
,
591 extra_link_args
= lflags
,
594 wxpExtensions
.append(ext
)
597 #----------------------------------------------------------------------
598 # Define the GIZMOS extension module
599 #----------------------------------------------------------------------
602 msg('Preparing GIZMOS...')
603 location
= 'contrib/gizmos'
605 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
606 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
608 ext
= Extension('_gizmos',
609 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
611 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
612 define_macros
= defines
,
614 library_dirs
= libdirs
,
615 libraries
= libs
+ makeLibName('gizmos'),
617 extra_compile_args
= cflags
,
618 extra_link_args
= lflags
,
621 wxpExtensions
.append(ext
)
625 #----------------------------------------------------------------------
626 # Define the DLLWIDGET extension module
627 #----------------------------------------------------------------------
630 msg('Preparing DLLWIDGET...')
631 location
= 'contrib/dllwidget'
632 swig_files
= ['dllwidget_.i']
634 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
635 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
637 # copy a contrib project specific py module to the main package dir
638 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
639 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
641 ext
= Extension('dllwidget_c', [
642 '%s/dllwidget.cpp' % location
,
645 include_dirs
= includes
+ CONTRIBS_INC
,
646 define_macros
= defines
,
648 library_dirs
= libdirs
,
651 extra_compile_args
= cflags
,
652 extra_link_args
= lflags
,
655 wxpExtensions
.append(ext
)
660 #----------------------------------------------------------------------
661 # Tools, scripts data files, etc.
662 #----------------------------------------------------------------------
667 SCRIPTS
= [opj('scripts/helpviewer'),
668 opj('scripts/img2png'),
669 opj('scripts/img2py'),
670 opj('scripts/img2xpm'),
671 opj('scripts/pyalacarte'),
672 opj('scripts/pyalamode'),
673 opj('scripts/pycrust'),
674 opj('scripts/pyshell'),
675 opj('scripts/pywrap'),
676 opj('scripts/pywrap'),
677 opj('scripts/pywxrc'),
678 opj('scripts/xrced'),
683 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
684 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
685 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
691 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
692 i_files
= glob
.glob(opj("src/*.i")) + \
693 glob
.glob(opj("src/_*.py")) + \
694 glob
.glob(opj("src/*.swg"))
696 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
697 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
701 if INSTALL_MULTIVERSION
:
702 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
)
703 open("src/wx.pth", "w").write(EXTRA_PATH
)
704 CLEANUP
.append("src/wx.pth")
710 #----------------------------------------------------------------------
711 # Do the Setup/Build/Install/Whatever
712 #----------------------------------------------------------------------
714 if __name__
== "__main__":
717 setup(name
= 'wxPython',
719 description
= DESCRIPTION
,
720 long_description
= LONG_DESCRIPTION
,
722 author_email
= AUTHOR_EMAIL
,
724 download_url
= DOWNLOAD_URL
,
726 platforms
= PLATFORMS
,
727 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
730 packages
= ['wxPython',
732 'wxPython.lib.colourchooser',
733 'wxPython.lib.editor',
734 'wxPython.lib.mixins',
740 'wx.lib.colourchooser',
742 'wx.lib.floatcanvas',
751 extra_path
= EXTRA_PATH
,
753 ext_package
= PKGDIR
,
754 ext_modules
= wxpExtensions
,
756 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
760 data_files
= DATA_FILES
,
763 # Override some of the default distutils command classes with my own
764 cmdclass
= { 'install' : wx_install
,
765 'install_data': wx_smart_install_data
,
766 'install_headers': wx_install_headers
,
767 'clean': wx_extra_clean
,
772 if INSTALL_MULTIVERSION
:
773 setup(name
= 'wxPython-common',
775 description
= DESCRIPTION
,
776 long_description
= LONG_DESCRIPTION
,
778 author_email
= AUTHOR_EMAIL
,
780 download_url
= DOWNLOAD_URL
,
782 platforms
= PLATFORMS
,
783 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
786 package_dir
= { '': 'wxversion' }
,
787 py_modules
= ['wxversion'],
789 data_files
= [('', ['src/wx.pth'])],
791 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
794 cmdclass
= { 'install_data': wx_smart_install_data
,
798 #----------------------------------------------------------------------
799 #----------------------------------------------------------------------