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 # Define the CORE extension module
70 #----------------------------------------------------------------------
72 msg('Preparing CORE...')
73 swig_sources
= run_swig(['core.i'], 'src', GENDIR
, PKGDIR
,
74 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
81 'src/__core_rename.i',
82 'src/__core_reverse.txt',
102 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
103 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
106 # update the license files
108 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
109 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
110 CLEANUP
.append(opj('licence',file))
111 CLEANUP
.append('licence')
115 build_locale_dir(opj(PKGDIR
, 'locale'))
116 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
120 rc_file
= ['src/wxc.rc']
125 ext
= Extension('_core_', ['src/helpers.cpp',
127 ] + rc_file
+ swig_sources
,
129 include_dirs
= includes
,
130 define_macros
= defines
,
132 library_dirs
= libdirs
,
135 extra_compile_args
= cflags
,
136 extra_link_args
= lflags
,
140 wxpExtensions
.append(ext
)
146 # Extension for the GDI module
147 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
148 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
149 ['src/__gdi_rename.i',
168 ext
= Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources
,
169 include_dirs
= includes
,
170 define_macros
= defines
,
171 library_dirs
= libdirs
,
173 extra_compile_args
= cflags
,
174 extra_link_args
= lflags
,
177 wxpExtensions
.append(ext
)
184 # Extension for the windows module
185 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
186 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
187 ['src/__windows_rename.i',
188 'src/__windows_reverse.txt',
204 ext
= Extension('_windows_', swig_sources
,
205 include_dirs
= includes
,
206 define_macros
= defines
,
207 library_dirs
= libdirs
,
209 extra_compile_args
= cflags
,
210 extra_link_args
= lflags
,
213 wxpExtensions
.append(ext
)
218 # Extension for the controls module
219 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
220 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
221 [ 'src/__controls_rename.i',
222 'src/__controls_reverse.txt',
246 ext
= Extension('_controls_', swig_sources
,
247 include_dirs
= includes
,
248 define_macros
= defines
,
249 library_dirs
= libdirs
,
251 extra_compile_args
= cflags
,
252 extra_link_args
= lflags
,
255 wxpExtensions
.append(ext
)
260 # Extension for the misc module
261 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
262 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
263 [ 'src/__misc_rename.i',
264 'src/__misc_reverse.txt',
284 ext
= Extension('_misc_', swig_sources
,
285 include_dirs
= includes
,
286 define_macros
= defines
,
287 library_dirs
= libdirs
,
289 extra_compile_args
= cflags
,
290 extra_link_args
= lflags
,
293 wxpExtensions
.append(ext
)
298 ## Core modules that are not in the "core" namespace start here
301 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
302 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
303 ext
= Extension('_calendar', swig_sources
,
304 include_dirs
= includes
,
305 define_macros
= defines
,
306 library_dirs
= libdirs
,
308 extra_compile_args
= cflags
,
309 extra_link_args
= lflags
,
312 wxpExtensions
.append(ext
)
315 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
316 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
317 ext
= Extension('_grid', 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
)
330 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
331 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
332 ext
= Extension('_html', 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(['wizard.i'], 'src', GENDIR
, PKGDIR
,
346 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
347 ext
= Extension('_wizard', 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 swig_sources
= run_swig(['xrc.i'], 'src', GENDIR
, PKGDIR
,
361 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
362 [ 'src/_xrc_rename.i',
369 ext
= Extension('_xrc',
372 include_dirs
= includes
+ CONTRIBS_INC
,
373 define_macros
= defines
,
375 library_dirs
= libdirs
,
378 extra_compile_args
= cflags
,
379 extra_link_args
= lflags
,
381 wxpExtensions
.append(ext
)
384 #----------------------------------------------------------------------
385 # Define the GLCanvas extension module
386 #----------------------------------------------------------------------
389 msg('Preparing GLCANVAS...')
390 location
= 'contrib/glcanvas'
392 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
393 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
396 if os
.name
== 'posix':
397 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
398 gl_lflags
= gl_config
.split() + lflags
401 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
404 ext
= Extension('_glcanvas',
407 include_dirs
= includes
+ CONTRIBS_INC
,
408 define_macros
= defines
,
410 library_dirs
= libdirs
,
413 extra_compile_args
= cflags
,
414 extra_link_args
= gl_lflags
,
417 wxpExtensions
.append(ext
)
420 #----------------------------------------------------------------------
421 # Define the OGL extension module
422 #----------------------------------------------------------------------
425 msg('Preparing OGL...')
426 location
= 'contrib/ogl'
428 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
429 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
430 [ '%s/_oglbasic.i' % location
,
431 '%s/_oglshapes.i' % location
,
432 '%s/_oglshapes2.i' % location
,
433 '%s/_oglcanvas.i' % location
,
434 '%s/_ogldefs.i' % location
,
437 ext
= Extension('_ogl',
440 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
441 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
443 library_dirs
= libdirs
,
444 libraries
= libs
+ makeLibName('ogl'),
446 extra_compile_args
= cflags
,
447 extra_link_args
= lflags
,
450 wxpExtensions
.append(ext
)
454 #----------------------------------------------------------------------
455 # Define the STC extension module
456 #----------------------------------------------------------------------
459 msg('Preparing STC...')
460 location
= 'contrib/stc'
462 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
464 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
466 ## NOTE: need to add something like this to the stc.bkl...
468 ## # Check if gen_iface needs to be run for the wxSTC sources
469 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
470 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
471 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
473 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
475 ## os.chdir(opj(CTRB_SRC, 'stc'))
476 ## sys.path.insert(0, os.curdir)
478 ## gen_iface.main([])
482 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
483 USE_SWIG
, swig_force
,
484 swig_args
+ ['-I'+STC_H
, '-I'+location
],
485 [opj(STC_H
, 'stc.h')] + swig_deps
)
487 ext
= Extension('_stc',
490 include_dirs
= includes
+ CONTRIBS_INC
,
491 define_macros
= defines
,
493 library_dirs
= libdirs
,
494 libraries
= libs
+ makeLibName('stc'),
496 extra_compile_args
= cflags
,
497 extra_link_args
= lflags
,
500 wxpExtensions
.append(ext
)
504 #----------------------------------------------------------------------
505 # Define the IEWIN extension module (experimental)
506 #----------------------------------------------------------------------
509 msg('Preparing IEWIN...')
510 location
= 'contrib/iewin'
512 swig_files
= ['iewin.i', ]
514 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
515 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
518 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
519 '%s/wxactivex.cpp' % location
,
522 include_dirs
= includes
+ CONTRIBS_INC
,
523 define_macros
= defines
,
525 library_dirs
= libdirs
,
528 extra_compile_args
= cflags
,
529 extra_link_args
= lflags
,
532 wxpExtensions
.append(ext
)
535 #----------------------------------------------------------------------
536 # Define the ACTIVEX extension module (experimental)
537 #----------------------------------------------------------------------
540 msg('Preparing ACTIVEX...')
541 location
= 'contrib/activex'
542 axloc
= opj(location
, "wxie")
544 swig_files
= ['activex.i', ]
546 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
547 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
548 [ '%s/_activex_ex.py' % location
])
551 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
552 '%s/wxactivex.cpp' % axloc
,
555 include_dirs
= includes
+ [ axloc
],
556 define_macros
= defines
,
558 library_dirs
= libdirs
,
561 extra_compile_args
= cflags
,
562 extra_link_args
= lflags
,
565 wxpExtensions
.append(ext
)
568 #----------------------------------------------------------------------
569 # Define the GIZMOS extension module
570 #----------------------------------------------------------------------
573 msg('Preparing GIZMOS...')
574 location
= 'contrib/gizmos'
576 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
577 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
579 ext
= Extension('_gizmos',
580 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
582 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
583 define_macros
= defines
,
585 library_dirs
= libdirs
,
586 libraries
= libs
+ makeLibName('gizmos'),
588 extra_compile_args
= cflags
,
589 extra_link_args
= lflags
,
592 wxpExtensions
.append(ext
)
596 #----------------------------------------------------------------------
597 # Define the DLLWIDGET extension module
598 #----------------------------------------------------------------------
601 msg('Preparing DLLWIDGET...')
602 location
= 'contrib/dllwidget'
603 swig_files
= ['dllwidget_.i']
605 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
606 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
608 # copy a contrib project specific py module to the main package dir
609 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
610 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
612 ext
= Extension('dllwidget_c', [
613 '%s/dllwidget.cpp' % location
,
616 include_dirs
= includes
+ CONTRIBS_INC
,
617 define_macros
= defines
,
619 library_dirs
= libdirs
,
622 extra_compile_args
= cflags
,
623 extra_link_args
= lflags
,
626 wxpExtensions
.append(ext
)
630 #----------------------------------------------------------------------
631 # patch distutils if it can't cope with the "classifiers" or
632 # "download_url" keywords
633 #----------------------------------------------------------------------
635 if sys
.version
< '2.2.3':
636 from distutils
.dist
import DistributionMetadata
637 DistributionMetadata
.classifiers
= None
638 DistributionMetadata
.download_url
= None
641 #----------------------------------------------------------------------
642 # Tools, scripts data files, etc.
643 #----------------------------------------------------------------------
648 SCRIPTS
= [opj('scripts/helpviewer'),
649 opj('scripts/img2png'),
650 opj('scripts/img2py'),
651 opj('scripts/img2xpm'),
652 opj('scripts/pyalacarte'),
653 opj('scripts/pyalamode'),
654 opj('scripts/pycrust'),
655 opj('scripts/pyshell'),
656 opj('scripts/pywrap'),
657 opj('scripts/pywrap'),
658 opj('scripts/xrced'),
661 SCRIPTS
+= [opj('scripts/wxrc')]
665 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
666 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
667 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
673 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
674 i_files
= glob
.glob(opj("src/*.i")) + \
675 glob
.glob(opj("src/_*.py")) + \
676 glob
.glob(opj("src/*.swg"))
678 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
679 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
683 if INSTALL_MULTIVERSION
:
684 EXTRA_PATH
= getExtraPath()
685 open("src/wx.pth", "w").write(EXTRA_PATH
)
686 CLEANUP
.append("src/wx.pth")
692 #----------------------------------------------------------------------
693 # Do the Setup/Build/Install/Whatever
694 #----------------------------------------------------------------------
696 if __name__
== "__main__":
699 setup(name
= 'wxPython',
701 description
= DESCRIPTION
,
702 long_description
= LONG_DESCRIPTION
,
704 author_email
= AUTHOR_EMAIL
,
706 download_url
= DOWNLOAD_URL
,
708 platforms
= PLATFORMS
,
709 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
712 packages
= ['wxPython',
714 'wxPython.lib.colourchooser',
715 'wxPython.lib.editor',
716 'wxPython.lib.mixins',
722 'wx.lib.colourchooser',
724 'wx.lib.floatcanvas',
733 extra_path
= EXTRA_PATH
,
735 ext_package
= PKGDIR
,
736 ext_modules
= wxpExtensions
,
738 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
742 data_files
= DATA_FILES
,
745 # Override some of the default distutils command classes with my own
746 cmdclass
= { 'install' : wx_install
,
747 'install_data': wx_smart_install_data
,
748 'install_headers': wx_install_headers
,
749 'clean': wx_extra_clean
,
754 if INSTALL_MULTIVERSION
:
755 setup(name
= 'wxPython-common',
757 description
= DESCRIPTION
,
758 long_description
= LONG_DESCRIPTION
,
760 author_email
= AUTHOR_EMAIL
,
762 download_url
= DOWNLOAD_URL
,
764 platforms
= PLATFORMS
,
765 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
768 package_dir
= { '': 'wxversion' }
,
769 py_modules
= ['wxversion'],
771 data_files
= [('', ['src/wx.pth'])],
773 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
776 cmdclass
= { 'install_data': wx_smart_install_data
,
780 #----------------------------------------------------------------------
781 #----------------------------------------------------------------------