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