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 swig_sources
= run_swig(['media.i'], 'src', GENDIR
, PKGDIR
,
361 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
362 ext
= Extension('_media', swig_sources
,
363 include_dirs
= includes
,
364 define_macros
= defines
,
365 library_dirs
= libdirs
,
367 extra_compile_args
= cflags
,
368 extra_link_args
= lflags
,
371 wxpExtensions
.append(ext
)
374 swig_sources
= run_swig(['webkit.i'], 'src', GENDIR
, PKGDIR
,
375 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
376 ext
= Extension('_webkit', 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(['wizard.i'], 'src', GENDIR
, PKGDIR
,
390 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
391 ext
= Extension('_wizard', 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(['xrc.i'], 'src', GENDIR
, PKGDIR
,
405 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
406 [ 'src/_xrc_rename.i',
413 ext
= Extension('_xrc',
416 include_dirs
= includes
+ CONTRIBS_INC
,
417 define_macros
= defines
,
419 library_dirs
= libdirs
,
422 extra_compile_args
= cflags
,
423 extra_link_args
= lflags
,
425 wxpExtensions
.append(ext
)
428 #----------------------------------------------------------------------
429 # Define the GLCanvas extension module
430 #----------------------------------------------------------------------
433 msg('Preparing GLCANVAS...')
434 location
= 'contrib/glcanvas'
436 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
437 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
440 if os
.name
== 'posix':
441 gl_config
= os
.popen(WX_CONFIG
+ ' --libs gl', 'r').read()[:-1]
442 gl_lflags
= gl_config
.split() + lflags
445 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
448 ext
= Extension('_glcanvas',
451 include_dirs
= includes
+ CONTRIBS_INC
,
452 define_macros
= defines
,
454 library_dirs
= libdirs
,
457 extra_compile_args
= cflags
,
458 extra_link_args
= gl_lflags
,
461 wxpExtensions
.append(ext
)
464 #----------------------------------------------------------------------
465 # Define the OGL extension module
466 #----------------------------------------------------------------------
469 msg('Preparing OGL...')
470 location
= 'contrib/ogl'
472 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
473 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
474 [ '%s/_oglbasic.i' % location
,
475 '%s/_oglshapes.i' % location
,
476 '%s/_oglshapes2.i' % location
,
477 '%s/_oglcanvas.i' % location
,
478 '%s/_ogldefs.i' % location
,
481 ext
= Extension('_ogl',
484 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
485 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
487 library_dirs
= libdirs
,
488 libraries
= libs
+ makeLibName('ogl'),
490 extra_compile_args
= cflags
,
491 extra_link_args
= lflags
,
494 wxpExtensions
.append(ext
)
498 #----------------------------------------------------------------------
499 # Define the STC extension module
500 #----------------------------------------------------------------------
503 msg('Preparing STC...')
504 location
= 'contrib/stc'
506 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
508 # STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
510 ## NOTE: need to add something like this to the stc.bkl...
512 ## # Check if gen_iface needs to be run for the wxSTC sources
513 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
514 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
515 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
517 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
519 ## os.chdir(opj(CTRB_SRC, 'stc'))
520 ## sys.path.insert(0, os.curdir)
522 ## gen_iface.main([])
526 swig_sources
= run_swig(['stc.i'], location
, GENDIR
, PKGDIR
,
527 USE_SWIG
, swig_force
,
528 swig_args
+ ['-I'+STC_H
, '-I'+location
],
529 [opj(STC_H
, 'stc.h')] + swig_deps
)
531 ext
= Extension('_stc',
534 include_dirs
= includes
+ CONTRIBS_INC
,
535 define_macros
= defines
,
537 library_dirs
= libdirs
,
538 libraries
= libs
+ makeLibName('stc'),
540 extra_compile_args
= cflags
,
541 extra_link_args
= lflags
,
544 wxpExtensions
.append(ext
)
548 #----------------------------------------------------------------------
549 # Define the IEWIN extension module (experimental)
550 #----------------------------------------------------------------------
553 msg('Preparing IEWIN...')
554 location
= 'contrib/iewin'
556 swig_files
= ['iewin.i', ]
558 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
559 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
562 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
563 '%s/wxactivex.cpp' % location
,
566 include_dirs
= includes
+ CONTRIBS_INC
,
567 define_macros
= defines
,
569 library_dirs
= libdirs
,
572 extra_compile_args
= cflags
,
573 extra_link_args
= lflags
,
576 wxpExtensions
.append(ext
)
579 #----------------------------------------------------------------------
580 # Define the ACTIVEX extension module (experimental)
581 #----------------------------------------------------------------------
584 msg('Preparing ACTIVEX...')
585 location
= 'contrib/activex'
586 axloc
= opj(location
, "wxie")
588 swig_files
= ['activex.i', ]
590 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
591 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
592 [ '%s/_activex_ex.py' % location
])
595 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
596 '%s/wxactivex.cpp' % axloc
,
599 include_dirs
= includes
+ [ axloc
],
600 define_macros
= defines
,
602 library_dirs
= libdirs
,
605 extra_compile_args
= cflags
,
606 extra_link_args
= lflags
,
609 wxpExtensions
.append(ext
)
612 #----------------------------------------------------------------------
613 # Define the GIZMOS extension module
614 #----------------------------------------------------------------------
617 msg('Preparing GIZMOS...')
618 location
= 'contrib/gizmos'
620 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
621 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
623 ext
= Extension('_gizmos',
624 [ '%s/treelistctrl.cpp' % opj(location
, 'wxCode/src') ] + swig_sources
,
626 include_dirs
= includes
+ [ location
, opj(location
, 'wxCode/include') ] + CONTRIBS_INC
,
627 define_macros
= defines
,
629 library_dirs
= libdirs
,
630 libraries
= libs
+ makeLibName('gizmos'),
632 extra_compile_args
= cflags
,
633 extra_link_args
= lflags
,
636 wxpExtensions
.append(ext
)
640 #----------------------------------------------------------------------
641 # Define the DLLWIDGET extension module
642 #----------------------------------------------------------------------
645 msg('Preparing DLLWIDGET...')
646 location
= 'contrib/dllwidget'
647 swig_files
= ['dllwidget_.i']
649 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
650 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
652 # copy a contrib project specific py module to the main package dir
653 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
654 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
656 ext
= Extension('dllwidget_c', [
657 '%s/dllwidget.cpp' % location
,
660 include_dirs
= includes
+ CONTRIBS_INC
,
661 define_macros
= defines
,
663 library_dirs
= libdirs
,
666 extra_compile_args
= cflags
,
667 extra_link_args
= lflags
,
670 wxpExtensions
.append(ext
)
675 #----------------------------------------------------------------------
676 # Tools, scripts data files, etc.
677 #----------------------------------------------------------------------
682 SCRIPTS
= [opj('scripts/helpviewer'),
683 opj('scripts/img2png'),
684 opj('scripts/img2py'),
685 opj('scripts/img2xpm'),
686 opj('scripts/pyalacarte'),
687 opj('scripts/pyalamode'),
688 opj('scripts/pycrust'),
689 opj('scripts/pyshell'),
690 opj('scripts/pywrap'),
691 opj('scripts/pywrap'),
692 opj('scripts/pywxrc'),
693 opj('scripts/xrced'),
698 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
699 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
700 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
706 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
707 i_files
= glob
.glob(opj("src/*.i")) + \
708 glob
.glob(opj("src/_*.py")) + \
709 glob
.glob(opj("src/*.swg"))
711 HEADERS
= zip(h_files
, ["/wxPython"]*len(h_files
)) + \
712 zip(i_files
, ["/wxPython/i_files"]*len(i_files
))
716 if INSTALL_MULTIVERSION
:
717 EXTRA_PATH
= getExtraPath(addOpts
=EP_ADD_OPTS
)
718 open("src/wx.pth", "w").write(EXTRA_PATH
)
719 CLEANUP
.append("src/wx.pth")
725 #----------------------------------------------------------------------
726 # Do the Setup/Build/Install/Whatever
727 #----------------------------------------------------------------------
729 if __name__
== "__main__":
732 setup(name
= 'wxPython',
734 description
= DESCRIPTION
,
735 long_description
= LONG_DESCRIPTION
,
737 author_email
= AUTHOR_EMAIL
,
739 download_url
= DOWNLOAD_URL
,
741 platforms
= PLATFORMS
,
742 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
745 packages
= ['wxPython',
747 'wxPython.lib.colourchooser',
748 'wxPython.lib.editor',
749 'wxPython.lib.mixins',
755 'wx.lib.colourchooser',
757 'wx.lib.floatcanvas',
766 extra_path
= EXTRA_PATH
,
768 ext_package
= PKGDIR
,
769 ext_modules
= wxpExtensions
,
771 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
775 data_files
= DATA_FILES
,
778 # Override some of the default distutils command classes with my own
779 cmdclass
= { 'install' : wx_install
,
780 'install_data': wx_smart_install_data
,
781 'install_headers': wx_install_headers
,
782 'clean': wx_extra_clean
,
787 if INSTALL_MULTIVERSION
:
788 setup(name
= 'wxPython-common',
790 description
= DESCRIPTION
,
791 long_description
= LONG_DESCRIPTION
,
793 author_email
= AUTHOR_EMAIL
,
795 download_url
= DOWNLOAD_URL
,
797 platforms
= PLATFORMS
,
798 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
801 package_dir
= { '': 'wxversion' }
,
802 py_modules
= ['wxversion'],
804 data_files
= [('', ['src/wx.pth'])],
806 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
809 cmdclass
= { 'install_data': wx_smart_install_data
,
813 #----------------------------------------------------------------------
814 #----------------------------------------------------------------------