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
+
82 'src/_core_reverse.txt',
100 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
101 CLEANUP
.append(opj(PKGDIR
, '__init__.py'))
104 # update the license files
106 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
107 copy_file(opj(WXDIR
, 'docs', file), opj('licence',file), update
=1, verbose
=0)
108 CLEANUP
.append(opj('licence',file))
109 CLEANUP
.append('licence')
113 build_locale_dir(opj(PKGDIR
, 'locale'))
114 DATA_FILES
+= build_locale_list(opj(PKGDIR
, 'locale'))
118 rc_file
= ['src/wxc.rc']
123 ext
= Extension('_core', ['src/helpers.cpp',
125 ] + rc_file
+ swig_sources
,
127 include_dirs
= includes
,
128 define_macros
= defines
,
130 library_dirs
= libdirs
,
133 extra_compile_args
= cflags
,
134 extra_link_args
= lflags
,
138 wxpExtensions
.append(ext
)
144 # Extension for the GDI module
145 swig_sources
= run_swig(['gdi.i'], 'src', GENDIR
, PKGDIR
,
146 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
147 ['src/_gdi_rename.i',
165 ext
= Extension('_gdi', ['src/drawlist.cpp'] + swig_sources
,
166 include_dirs
= includes
,
167 define_macros
= defines
,
168 library_dirs
= libdirs
,
170 extra_compile_args
= cflags
,
171 extra_link_args
= lflags
,
174 wxpExtensions
.append(ext
)
181 # Extension for the windows module
182 swig_sources
= run_swig(['windows.i'], 'src', GENDIR
, PKGDIR
,
183 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
184 ['src/_windows_rename.i',
185 'src/_windows_reverse.txt',
200 ext
= Extension('_windows', swig_sources
,
201 include_dirs
= includes
,
202 define_macros
= defines
,
203 library_dirs
= libdirs
,
205 extra_compile_args
= cflags
,
206 extra_link_args
= lflags
,
209 wxpExtensions
.append(ext
)
214 # Extension for the controls module
215 swig_sources
= run_swig(['controls.i'], 'src', GENDIR
, PKGDIR
,
216 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
217 [ 'src/_controls_rename.i',
218 'src/_controls_reverse.txt',
241 ext
= Extension('_controls', swig_sources
,
242 include_dirs
= includes
,
243 define_macros
= defines
,
244 library_dirs
= libdirs
,
246 extra_compile_args
= cflags
,
247 extra_link_args
= lflags
,
250 wxpExtensions
.append(ext
)
255 # Extension for the misc module
256 swig_sources
= run_swig(['misc.i'], 'src', GENDIR
, PKGDIR
,
257 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
276 ext
= Extension('_misc', swig_sources
,
277 include_dirs
= includes
,
278 define_macros
= defines
,
279 library_dirs
= libdirs
,
281 extra_compile_args
= cflags
,
282 extra_link_args
= lflags
,
285 wxpExtensions
.append(ext
)
290 ## Core modules that are not in the "core" namespace start here
293 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
294 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
295 ext
= Extension('_calendar', swig_sources
,
296 include_dirs
= includes
,
297 define_macros
= defines
,
298 library_dirs
= libdirs
,
300 extra_compile_args
= cflags
,
301 extra_link_args
= lflags
,
304 wxpExtensions
.append(ext
)
307 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
308 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
309 ext
= Extension('_grid', swig_sources
,
310 include_dirs
= includes
,
311 define_macros
= defines
,
312 library_dirs
= libdirs
,
314 extra_compile_args
= cflags
,
315 extra_link_args
= lflags
,
318 wxpExtensions
.append(ext
)
322 swig_sources
= run_swig(['html.i'], 'src', GENDIR
, PKGDIR
,
323 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
324 ext
= Extension('_html', swig_sources
,
325 include_dirs
= includes
,
326 define_macros
= defines
,
327 library_dirs
= libdirs
,
329 extra_compile_args
= cflags
,
330 extra_link_args
= lflags
,
333 wxpExtensions
.append(ext
)
337 swig_sources
= run_swig(['wizard.i'], 'src', GENDIR
, PKGDIR
,
338 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
339 ext
= Extension('_wizard', swig_sources
,
340 include_dirs
= includes
,
341 define_macros
= defines
,
342 library_dirs
= libdirs
,
344 extra_compile_args
= cflags
,
345 extra_link_args
= lflags
,
348 wxpExtensions
.append(ext
)
351 #----------------------------------------------------------------------
352 # Define the GLCanvas extension module
353 #----------------------------------------------------------------------
356 msg('Preparing GLCANVAS...')
357 location
= 'contrib/glcanvas'
359 swig_sources
= run_swig(['glcanvas.i'], location
, GENDIR
, PKGDIR
,
360 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
363 if os
.name
== 'posix':
364 gl_config
= os
.popen(WX_CONFIG
+ ' --gl-libs', 'r').read()[:-1]
365 gl_lflags
= gl_config
.split() + lflags
368 gl_libs
= libs
+ ['opengl32', 'glu32'] + makeLibName('gl')
371 ext
= Extension('_glcanvas',
374 include_dirs
= includes
+ CONTRIBS_INC
,
375 define_macros
= defines
,
377 library_dirs
= libdirs
,
380 extra_compile_args
= cflags
,
381 extra_link_args
= gl_lflags
,
384 wxpExtensions
.append(ext
)
387 #----------------------------------------------------------------------
388 # Define the OGL extension module
389 #----------------------------------------------------------------------
392 msg('Preparing OGL...')
393 location
= 'contrib/ogl'
395 swig_sources
= run_swig(['ogl.i'], location
, GENDIR
, PKGDIR
,
396 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
397 [ '%s/_oglbasic.i' % location
,
398 '%s/_oglshapes.i' % location
,
399 '%s/_oglshapes2.i' % location
,
400 '%s/_oglcanvas.i' % location
,
401 '%s/_ogldefs.i' % location
,
404 ext
= Extension('_ogl',
407 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
408 define_macros
= defines
+ [('wxUSE_DEPRECATED', '0')],
410 library_dirs
= libdirs
,
411 libraries
= libs
+ makeLibName('ogl'),
413 extra_compile_args
= cflags
,
414 extra_link_args
= lflags
,
417 wxpExtensions
.append(ext
)
421 #----------------------------------------------------------------------
422 # Define the STC extension module
423 #----------------------------------------------------------------------
426 msg('Preparing STC...')
427 location
= 'contrib/stc'
429 STC_H
= opj(WXDIR
, 'contrib', 'include/wx/stc')
431 STC_H
= opj(WXPREFIX
, 'include/wx/stc')
433 ## NOTE: need to add something like this to the stc.bkl...
435 ## # Check if gen_iface needs to be run for the wxSTC sources
436 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
437 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
438 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
440 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
442 ## os.chdir(opj(CTRB_SRC, 'stc'))
443 ## sys.path.insert(0, os.curdir)
445 ## gen_iface.main([])
449 swig_sources
= run_swig(['stc.i'], location
, '', PKGDIR
,
450 USE_SWIG
, swig_force
,
451 swig_args
+ ['-I'+STC_H
, '-I'+location
],
452 [opj(STC_H
, 'stc.h')] + swig_deps
)
454 ext
= Extension('_stc',
457 include_dirs
= includes
+ CONTRIBS_INC
,
458 define_macros
= defines
,
460 library_dirs
= libdirs
,
461 libraries
= libs
+ makeLibName('stc'),
463 extra_compile_args
= cflags
,
464 extra_link_args
= lflags
,
467 wxpExtensions
.append(ext
)
471 #----------------------------------------------------------------------
472 # Define the IEWIN extension module (experimental)
473 #----------------------------------------------------------------------
476 msg('Preparing IEWIN...')
477 location
= 'contrib/iewin'
479 swig_files
= ['iewin.i', ]
481 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
482 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
485 ext
= Extension('_iewin', ['%s/IEHtmlWin.cpp' % location
,
486 '%s/wxactivex.cpp' % location
,
489 include_dirs
= includes
+ CONTRIBS_INC
,
490 define_macros
= defines
,
492 library_dirs
= libdirs
,
495 extra_compile_args
= cflags
,
496 extra_link_args
= lflags
,
499 wxpExtensions
.append(ext
)
502 #----------------------------------------------------------------------
503 # Define the ACTIVEX extension module (experimental)
504 #----------------------------------------------------------------------
507 msg('Preparing ACTIVEX...')
508 location
= 'contrib/activex'
509 axloc
= opj(location
, "wxie")
511 swig_files
= ['activex.i', ]
513 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
514 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
515 [ '%s/_activex_ex.py' % location
])
518 ext
= Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc
,
519 '%s/wxactivex.cpp' % axloc
,
522 include_dirs
= includes
+ [ axloc
],
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 XRC extension module
537 #----------------------------------------------------------------------
540 msg('Preparing XRC...')
541 location
= 'contrib/xrc'
543 swig_sources
= run_swig(['xrc.i'], location
, '', PKGDIR
,
544 USE_SWIG
, swig_force
, swig_args
, swig_deps
+
545 [ '%s/_xrc_rename.i' % location
,
546 '%s/_xrc_ex.py' % location
,
547 '%s/_xmlres.i' % location
,
548 '%s/_xmlsub.i' % location
,
549 '%s/_xml.i' % location
,
550 '%s/_xmlhandler.i' % location
,
553 ext
= Extension('_xrc',
556 include_dirs
= includes
+ CONTRIBS_INC
,
557 define_macros
= defines
,
559 library_dirs
= libdirs
,
560 libraries
= libs
+ makeLibName('xrc'),
562 extra_compile_args
= cflags
,
563 extra_link_args
= lflags
,
566 wxpExtensions
.append(ext
)
570 #----------------------------------------------------------------------
571 # Define the GIZMOS extension module
572 #----------------------------------------------------------------------
575 msg('Preparing GIZMOS...')
576 location
= 'contrib/gizmos'
578 swig_sources
= run_swig(['gizmos.i'], location
, GENDIR
, PKGDIR
,
579 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
581 ext
= Extension('_gizmos',
582 [ '%s/treelistctrl.cpp' % location
] + swig_sources
,
584 include_dirs
= includes
+ [ location
] + CONTRIBS_INC
,
585 define_macros
= defines
,
587 library_dirs
= libdirs
,
588 libraries
= libs
+ makeLibName('gizmos'),
590 extra_compile_args
= cflags
,
591 extra_link_args
= lflags
,
594 wxpExtensions
.append(ext
)
598 #----------------------------------------------------------------------
599 # Define the DLLWIDGET extension module
600 #----------------------------------------------------------------------
603 msg('Preparing DLLWIDGET...')
604 location
= 'contrib/dllwidget'
605 swig_files
= ['dllwidget_.i']
607 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
608 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
610 # copy a contrib project specific py module to the main package dir
611 copy_file(opj(location
, 'dllwidget.py'), PKGDIR
, update
=1, verbose
=0)
612 CLEANUP
.append(opj(PKGDIR
, 'dllwidget.py'))
614 ext
= Extension('dllwidget_c', [
615 '%s/dllwidget.cpp' % location
,
618 include_dirs
= includes
+ CONTRIBS_INC
,
619 define_macros
= defines
,
621 library_dirs
= libdirs
,
624 extra_compile_args
= cflags
,
625 extra_link_args
= lflags
,
628 wxpExtensions
.append(ext
)
633 #----------------------------------------------------------------------
634 # Tools, scripts data files, etc.
635 #----------------------------------------------------------------------
640 SCRIPTS
= [opj('scripts/helpviewer'),
641 opj('scripts/img2png'),
642 opj('scripts/img2xpm'),
643 opj('scripts/img2py'),
644 opj('scripts/xrced'),
645 opj('scripts/pyshell'),
646 opj('scripts/pycrust'),
647 opj('scripts/pywrap'),
648 opj('scripts/pywrap'),
649 opj('scripts/pyalacarte'),
650 opj('scripts/pyalamode'),
654 DATA_FILES
+= find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
655 DATA_FILES
+= find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
656 DATA_FILES
+= find_data_files('wx', '*.txt', '*.css', '*.html')
662 h_files
= glob
.glob(opj("include/wx/wxPython/*.h"))
663 i_files
= glob
.glob(opj("src/*.i")) + \
664 glob
.glob(opj("src/_*.py")) + \
665 glob
.glob(opj("src/*.swg"))
667 HEADERS
= zip(h_files
, ["/include/wx/wxPython"]*len(h_files
)) + \
668 zip(i_files
, ["/include/wx/wxPython/i_files"]*len(i_files
))
670 #----------------------------------------------------------------------
671 # Do the Setup/Build/Install/Whatever
672 #----------------------------------------------------------------------
674 if __name__
== "__main__":
676 setup(name
= 'wxPython',
678 description
= DESCRIPTION
,
679 long_description
= LONG_DESCRIPTION
,
681 author_email
= AUTHOR_EMAIL
,
683 download_url
= DOWNLOAD_URL
,
685 platforms
= PLATFORMS
,
686 classifiers
= filter(None, CLASSIFIERS
.split("\n")),
689 packages
= ['wxPython',
691 'wxPython.lib.colourchooser',
692 'wxPython.lib.editor',
693 'wxPython.lib.mixins',
699 'wx.lib.colourchooser',
707 ext_package
= PKGDIR
,
708 ext_modules
= wxpExtensions
,
710 options
= { 'build' : { 'build_base' : BUILD_BASE }
,
714 data_files
= DATA_FILES
,
717 cmdclass
= { 'install_data': wx_smart_install_data
,
718 'install_headers': wx_install_headers
,
719 'clean': wx_extra_clean
,
724 #----------------------------------------------------------------------
725 #----------------------------------------------------------------------