]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
Cleanup obsolete samples
[wxWidgets.git] / wxPython / setup.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------
3 # Name: setup.py
4 # Purpose: Distutils script for building wxPython
5 #
6 # Author: Robin Dunn
7 #
8 # Created: 12-Oct-2000
9 # RCS-ID: $Id$
10 # Copyright: (c) 2000 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------
13
14 import sys
15
16
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
24 # to functions, etc.
25
26 sys.setup_is_main = __name__ == "__main__" # an icky hack!
27 from wx.build.config import *
28
29
30 #----------------------------------------------------------------------
31 # Update the version file
32 #----------------------------------------------------------------------
33
34 # The version file is unconditionally updated every time setup.py is
35 # run since the version string can change based on the UNICODE flag
36
37 open('wx/__version__.py', 'w').write("""\
38 # This file was generated by setup.py...
39
40 VERSION_STRING = '%(VERSION)s'
41 MAJOR_VERSION = %(VER_MAJOR)s
42 MINOR_VERSION = %(VER_MINOR)s
43 RELEASE_VERSION = %(VER_RELEASE)s
44 SUBREL_VERSION = %(VER_SUBREL)s
45
46 VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION,
47 SUBREL_VERSION, '%(VER_FLAGS)s')
48
49 RELEASE_NUMBER = RELEASE_VERSION # for compatibility
50 """ % globals())
51
52 CLEANUP.append('wx/__version__.py')
53
54
55 #----------------------------------------------------------------------
56 # Define the CORE extension module
57 #----------------------------------------------------------------------
58
59 msg('Preparing CORE...')
60 swig_sources = run_swig(['core.i'], 'src', GENDIR, PKGDIR,
61 USE_SWIG, swig_force, swig_args, swig_deps +
62 [ 'src/_accel.i',
63 'src/_app.i',
64 'src/_app_ex.py',
65 'src/_constraints.i',
66 'src/_core_api.i',
67 'src/_core_ex.py',
68 'src/_core_rename.i',
69 'src/_core_reverse.txt',
70 'src/_defs.i',
71 'src/_event.i',
72 'src/_event_ex.py',
73 'src/_evthandler.i',
74 'src/_filesys.i',
75 'src/_gdicmn.i',
76 'src/_image.i',
77 'src/_menu.i',
78 'src/_obj.i',
79 'src/_sizers.i',
80 'src/_gbsizer.i',
81 'src/_streams.i',
82 'src/_validator.i',
83 'src/_window.i',
84 'src/_control.i',
85 ])
86
87 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
88 CLEANUP.append(opj(PKGDIR, '__init__.py'))
89
90
91 # update the license files
92 mkpath('licence')
93 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
94 copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0)
95 CLEANUP.append(opj('licence',file))
96 CLEANUP.append('licence')
97
98
99 if os.name == 'nt':
100 build_locale_dir(opj(PKGDIR, 'locale'))
101 DATA_FILES += build_locale_list(opj(PKGDIR, 'locale'))
102
103
104 if os.name == 'nt':
105 rc_file = ['src/wxc.rc']
106 else:
107 rc_file = []
108
109
110 ext = Extension('_core', ['src/helpers.cpp',
111 'src/libpy.c',
112 ] + rc_file + swig_sources,
113
114 include_dirs = includes,
115 define_macros = defines,
116
117 library_dirs = libdirs,
118 libraries = libs,
119
120 extra_compile_args = cflags,
121 extra_link_args = lflags,
122
123 depends = depends
124 )
125 wxpExtensions.append(ext)
126
127
128
129
130
131 # Extension for the GDI module
132 swig_sources = run_swig(['gdi.i'], 'src', GENDIR, PKGDIR,
133 USE_SWIG, swig_force, swig_args, swig_deps +
134 ['src/_gdi_rename.i',
135 'src/_bitmap.i',
136 'src/_colour.i',
137 'src/_dc.i',
138 'src/_gdiobj.i',
139 'src/_imaglist.i',
140 'src/_region.i',
141 'src/_stockobjs.i',
142 'src/_effects.i',
143 'src/_intl.i',
144 'src/_intl_ex.py',
145 'src/_brush.i',
146 'src/_cursor.i',
147 'src/_font.i',
148 'src/_icon.i',
149 'src/_pen.i',
150 'src/_palette.i',
151 ])
152 ext = Extension('_gdi', ['src/drawlist.cpp'] + swig_sources,
153 include_dirs = includes,
154 define_macros = defines,
155 library_dirs = libdirs,
156 libraries = libs,
157 extra_compile_args = cflags,
158 extra_link_args = lflags,
159 depends = depends
160 )
161 wxpExtensions.append(ext)
162
163
164
165
166
167
168 # Extension for the windows module
169 swig_sources = run_swig(['windows.i'], 'src', GENDIR, PKGDIR,
170 USE_SWIG, swig_force, swig_args, swig_deps +
171 ['src/_windows_rename.i',
172 'src/_windows_reverse.txt',
173 'src/_panel.i',
174 'src/_toplvl.i',
175 'src/_statusbar.i',
176 'src/_splitter.i',
177 'src/_sashwin.i',
178 'src/_popupwin.i',
179 'src/_tipwin.i',
180 'src/_vscroll.i',
181 'src/_taskbar.i',
182 'src/_cmndlgs.i',
183 'src/_mdi.i',
184 'src/_pywindows.i',
185 'src/_printfw.i',
186 ])
187 ext = Extension('_windows', swig_sources,
188 include_dirs = includes,
189 define_macros = defines,
190 library_dirs = libdirs,
191 libraries = libs,
192 extra_compile_args = cflags,
193 extra_link_args = lflags,
194 depends = depends
195 )
196 wxpExtensions.append(ext)
197
198
199
200
201 # Extension for the controls module
202 swig_sources = run_swig(['controls.i'], 'src', GENDIR, PKGDIR,
203 USE_SWIG, swig_force, swig_args, swig_deps +
204 [ 'src/_controls_rename.i',
205 'src/_controls_reverse.txt',
206 'src/_toolbar.i',
207 'src/_button.i',
208 'src/_checkbox.i',
209 'src/_choice.i',
210 'src/_combobox.i',
211 'src/_gauge.i',
212 'src/_statctrls.i',
213 'src/_listbox.i',
214 'src/_textctrl.i',
215 'src/_scrolbar.i',
216 'src/_spin.i',
217 'src/_radio.i',
218 'src/_slider.i',
219 'src/_tglbtn.i',
220 'src/_notebook.i',
221 'src/_listctrl.i',
222 'src/_treectrl.i',
223 'src/_dirctrl.i',
224 'src/_pycontrol.i',
225 'src/_cshelp.i',
226 'src/_dragimg.i',
227 ])
228 ext = Extension('_controls', swig_sources,
229 include_dirs = includes,
230 define_macros = defines,
231 library_dirs = libdirs,
232 libraries = libs,
233 extra_compile_args = cflags,
234 extra_link_args = lflags,
235 depends = depends
236 )
237 wxpExtensions.append(ext)
238
239
240
241
242 # Extension for the misc module
243 swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR,
244 USE_SWIG, swig_force, swig_args, swig_deps +
245 [ 'src/_settings.i',
246 'src/_functions.i',
247 'src/_misc.i',
248 'src/_tipdlg.i',
249 'src/_timer.i',
250 'src/_log.i',
251 'src/_process.i',
252 'src/_joystick.i',
253 'src/_sound.i',
254 'src/_mimetype.i',
255 'src/_artprov.i',
256 'src/_config.i',
257 'src/_datetime.i',
258 'src/_dataobj.i',
259 'src/_dnd.i',
260 'src/_display.i',
261 'src/_clipbrd.i',
262 ])
263 ext = Extension('_misc', swig_sources,
264 include_dirs = includes,
265 define_macros = defines,
266 library_dirs = libdirs,
267 libraries = libs,
268 extra_compile_args = cflags,
269 extra_link_args = lflags,
270 depends = depends
271 )
272 wxpExtensions.append(ext)
273
274
275
276 ##
277 ## Core modules that are not in the "core" namespace start here
278 ##
279
280 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
281 USE_SWIG, swig_force, swig_args, swig_deps)
282 ext = Extension('_calendar', swig_sources,
283 include_dirs = includes,
284 define_macros = defines,
285 library_dirs = libdirs,
286 libraries = libs,
287 extra_compile_args = cflags,
288 extra_link_args = lflags,
289 depends = depends
290 )
291 wxpExtensions.append(ext)
292
293
294 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
295 USE_SWIG, swig_force, swig_args, swig_deps)
296 ext = Extension('_grid', swig_sources,
297 include_dirs = includes,
298 define_macros = defines,
299 library_dirs = libdirs,
300 libraries = libs,
301 extra_compile_args = cflags,
302 extra_link_args = lflags,
303 depends = depends
304 )
305 wxpExtensions.append(ext)
306
307
308
309 swig_sources = run_swig(['html.i'], 'src', GENDIR, PKGDIR,
310 USE_SWIG, swig_force, swig_args, swig_deps)
311 ext = Extension('_html', swig_sources,
312 include_dirs = includes,
313 define_macros = defines,
314 library_dirs = libdirs,
315 libraries = libs,
316 extra_compile_args = cflags,
317 extra_link_args = lflags,
318 depends = depends
319 )
320 wxpExtensions.append(ext)
321
322
323
324 swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR,
325 USE_SWIG, swig_force, swig_args, swig_deps)
326 ext = Extension('_wizard', swig_sources,
327 include_dirs = includes,
328 define_macros = defines,
329 library_dirs = libdirs,
330 libraries = libs,
331 extra_compile_args = cflags,
332 extra_link_args = lflags,
333 depends = depends
334 )
335 wxpExtensions.append(ext)
336
337
338 #----------------------------------------------------------------------
339 # Define the GLCanvas extension module
340 #----------------------------------------------------------------------
341
342 if BUILD_GLCANVAS:
343 msg('Preparing GLCANVAS...')
344 location = 'contrib/glcanvas'
345
346 swig_sources = run_swig(['glcanvas.i'], location, GENDIR, PKGDIR,
347 USE_SWIG, swig_force, swig_args, swig_deps)
348
349 gl_libs = []
350 if os.name == 'posix':
351 gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
352 gl_lflags = gl_config.split() + lflags
353 gl_libs = libs
354 else:
355 gl_libs = libs + ['opengl32', 'glu32'] + makeLibName('gl')
356 gl_lflags = lflags
357
358 ext = Extension('_glcanvas',
359 swig_sources,
360
361 include_dirs = includes + CONTRIBS_INC,
362 define_macros = defines,
363
364 library_dirs = libdirs,
365 libraries = gl_libs,
366
367 extra_compile_args = cflags,
368 extra_link_args = gl_lflags,
369 )
370
371 wxpExtensions.append(ext)
372
373
374 #----------------------------------------------------------------------
375 # Define the OGL extension module
376 #----------------------------------------------------------------------
377
378 if BUILD_OGL:
379 msg('Preparing OGL...')
380 location = 'contrib/ogl'
381
382 swig_sources = run_swig(['ogl.i'], location, GENDIR, PKGDIR,
383 USE_SWIG, swig_force, swig_args, swig_deps +
384 [ '%s/_oglbasic.i' % location,
385 '%s/_oglshapes.i' % location,
386 '%s/_oglshapes2.i' % location,
387 '%s/_oglcanvas.i' % location,
388 '%s/_ogldefs.i' % location,
389 ])
390
391 ext = Extension('_ogl',
392 swig_sources,
393
394 include_dirs = includes + [ location ] + CONTRIBS_INC,
395 define_macros = defines + [('wxUSE_DEPRECATED', '0')],
396
397 library_dirs = libdirs,
398 libraries = libs + makeLibName('ogl'),
399
400 extra_compile_args = cflags,
401 extra_link_args = lflags,
402 )
403
404 wxpExtensions.append(ext)
405
406
407
408 #----------------------------------------------------------------------
409 # Define the STC extension module
410 #----------------------------------------------------------------------
411
412 if BUILD_STC:
413 msg('Preparing STC...')
414 location = 'contrib/stc'
415 if os.name == 'nt':
416 STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
417 else:
418 STC_H = opj(WXPREFIX, 'include/wx/stc')
419
420 ## NOTE: need to add something like this to the stc.bkl...
421
422 ## # Check if gen_iface needs to be run for the wxSTC sources
423 ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or
424 ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or
425 ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))):
426
427 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
428 ## cwd = os.getcwd()
429 ## os.chdir(opj(CTRB_SRC, 'stc'))
430 ## sys.path.insert(0, os.curdir)
431 ## import gen_iface
432 ## gen_iface.main([])
433 ## os.chdir(cwd)
434
435
436 swig_sources = run_swig(['stc.i'], location, '', PKGDIR,
437 USE_SWIG, swig_force,
438 swig_args + ['-I'+STC_H, '-I'+location],
439 [opj(STC_H, 'stc.h')] + swig_deps)
440
441 ext = Extension('_stc',
442 swig_sources,
443
444 include_dirs = includes + CONTRIBS_INC,
445 define_macros = defines,
446
447 library_dirs = libdirs,
448 libraries = libs + makeLibName('stc'),
449
450 extra_compile_args = cflags,
451 extra_link_args = lflags,
452 )
453
454 wxpExtensions.append(ext)
455
456
457
458 #----------------------------------------------------------------------
459 # Define the IEWIN extension module (experimental)
460 #----------------------------------------------------------------------
461
462 if BUILD_IEWIN:
463 msg('Preparing IEWIN...')
464 location = 'contrib/iewin'
465
466 swig_files = ['iewin.i', ]
467
468 swig_sources = run_swig(swig_files, location, '', PKGDIR,
469 USE_SWIG, swig_force, swig_args, swig_deps)
470
471
472 ext = Extension('_iewin', ['%s/IEHtmlWin.cpp' % location,
473 '%s/wxactivex.cpp' % location,
474 ] + swig_sources,
475
476 include_dirs = includes + CONTRIBS_INC,
477 define_macros = defines,
478
479 library_dirs = libdirs,
480 libraries = libs,
481
482 extra_compile_args = cflags,
483 extra_link_args = lflags,
484 )
485
486 wxpExtensions.append(ext)
487
488
489 #----------------------------------------------------------------------
490 # Define the ACTIVEX extension module (experimental)
491 #----------------------------------------------------------------------
492
493 if BUILD_ACTIVEX:
494 msg('Preparing ACTIVEX...')
495 location = 'contrib/activex'
496 axloc = opj(location, "wxie")
497
498 swig_files = ['activex.i', ]
499
500 swig_sources = run_swig(swig_files, location, '', PKGDIR,
501 USE_SWIG, swig_force, swig_args, swig_deps +
502 [ '%s/_activex_ex.py' % location])
503
504
505 ext = Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc,
506 '%s/wxactivex.cpp' % axloc,
507 ] + swig_sources,
508
509 include_dirs = includes + [ axloc ],
510 define_macros = defines,
511
512 library_dirs = libdirs,
513 libraries = libs,
514
515 extra_compile_args = cflags,
516 extra_link_args = lflags,
517 )
518
519 wxpExtensions.append(ext)
520
521
522 #----------------------------------------------------------------------
523 # Define the XRC extension module
524 #----------------------------------------------------------------------
525
526 if BUILD_XRC:
527 msg('Preparing XRC...')
528 location = 'contrib/xrc'
529
530 swig_sources = run_swig(['xrc.i'], location, '', PKGDIR,
531 USE_SWIG, swig_force, swig_args, swig_deps +
532 [ '%s/_xrc_rename.i' % location,
533 '%s/_xrc_ex.py' % location,
534 '%s/_xmlres.i' % location,
535 '%s/_xmlsub.i' % location,
536 '%s/_xml.i' % location,
537 '%s/_xmlhandler.i' % location,
538 ])
539
540 ext = Extension('_xrc',
541 swig_sources,
542
543 include_dirs = includes + CONTRIBS_INC,
544 define_macros = defines,
545
546 library_dirs = libdirs,
547 libraries = libs + makeLibName('xrc'),
548
549 extra_compile_args = cflags,
550 extra_link_args = lflags,
551 )
552
553 wxpExtensions.append(ext)
554
555
556
557 #----------------------------------------------------------------------
558 # Define the GIZMOS extension module
559 #----------------------------------------------------------------------
560
561 if BUILD_GIZMOS:
562 msg('Preparing GIZMOS...')
563 location = 'contrib/gizmos'
564
565 swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR,
566 USE_SWIG, swig_force, swig_args, swig_deps)
567
568 ext = Extension('_gizmos',
569 [ '%s/treelistctrl.cpp' % location ] + swig_sources,
570
571 include_dirs = includes + [ location ] + CONTRIBS_INC,
572 define_macros = defines,
573
574 library_dirs = libdirs,
575 libraries = libs + makeLibName('gizmos'),
576
577 extra_compile_args = cflags,
578 extra_link_args = lflags,
579 )
580
581 wxpExtensions.append(ext)
582
583
584
585 #----------------------------------------------------------------------
586 # Define the DLLWIDGET extension module
587 #----------------------------------------------------------------------
588
589 if BUILD_DLLWIDGET:
590 msg('Preparing DLLWIDGET...')
591 location = 'contrib/dllwidget'
592 swig_files = ['dllwidget_.i']
593
594 swig_sources = run_swig(swig_files, location, '', PKGDIR,
595 USE_SWIG, swig_force, swig_args, swig_deps)
596
597 # copy a contrib project specific py module to the main package dir
598 copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0)
599 CLEANUP.append(opj(PKGDIR, 'dllwidget.py'))
600
601 ext = Extension('dllwidget_c', [
602 '%s/dllwidget.cpp' % location,
603 ] + swig_sources,
604
605 include_dirs = includes + CONTRIBS_INC,
606 define_macros = defines,
607
608 library_dirs = libdirs,
609 libraries = libs,
610
611 extra_compile_args = cflags,
612 extra_link_args = lflags,
613 )
614
615 wxpExtensions.append(ext)
616
617
618
619
620 #----------------------------------------------------------------------
621 # Tools, scripts data files, etc.
622 #----------------------------------------------------------------------
623
624 if NO_SCRIPTS:
625 SCRIPTS = None
626 else:
627 SCRIPTS = [opj('scripts/helpviewer'),
628 opj('scripts/img2png'),
629 opj('scripts/img2xpm'),
630 opj('scripts/img2py'),
631 opj('scripts/xrced'),
632 opj('scripts/pyshell'),
633 opj('scripts/pycrust'),
634 opj('scripts/pywrap'),
635 opj('scripts/pywrap'),
636 opj('scripts/pyalacarte'),
637 opj('scripts/pyalamode'),
638 ]
639
640
641 DATA_FILES += find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
642 DATA_FILES += find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
643 DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html')
644
645
646 if NO_HEADERS:
647 HEADERS = None
648 else:
649 h_files = glob.glob(opj("include/wx/wxPython/*.h"))
650 i_files = glob.glob(opj("src/*.i")) + \
651 glob.glob(opj("src/_*.py")) + \
652 glob.glob(opj("src/*.swg"))
653
654 HEADERS = zip(h_files, ["/include/wx/wxPython"]*len(h_files)) + \
655 zip(i_files, ["/include/wx/wxPython/i_files"]*len(i_files))
656
657 #----------------------------------------------------------------------
658 # Do the Setup/Build/Install/Whatever
659 #----------------------------------------------------------------------
660
661 if __name__ == "__main__":
662 if not PREP_ONLY:
663 setup(name = 'wxPython',
664 version = VERSION,
665 description = DESCRIPTION,
666 long_description = LONG_DESCRIPTION,
667 author = AUTHOR,
668 author_email = AUTHOR_EMAIL,
669 url = URL,
670 download_url = DOWNLOAD_URL,
671 license = LICENSE,
672 platforms = PLATFORMS,
673 classifiers = filter(None, CLASSIFIERS.split("\n")),
674 keywords = KEYWORDS,
675
676 packages = ['wxPython',
677 'wxPython.lib',
678 'wxPython.lib.colourchooser',
679 'wxPython.lib.editor',
680 'wxPython.lib.mixins',
681 'wxPython.tools',
682
683 'wx',
684 'wx.build',
685 'wx.lib',
686 'wx.lib.colourchooser',
687 'wx.lib.editor',
688 'wx.lib.mixins',
689 'wx.py',
690 'wx.tools',
691 'wx.tools.XRCed',
692 ],
693
694 ext_package = PKGDIR,
695 ext_modules = wxpExtensions,
696
697 options = { 'build' : { 'build_base' : BUILD_BASE },
698 },
699
700 scripts = SCRIPTS,
701 data_files = DATA_FILES,
702 headers = HEADERS,
703
704 cmdclass = { 'install_data': wx_smart_install_data,
705 'install_headers': wx_install_headers,
706 'clean': wx_extra_clean,
707 },
708 )
709
710
711 #----------------------------------------------------------------------
712 #----------------------------------------------------------------------