]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
Compile fix
[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/_evtloop.i',
87 'src/_evthandler.i',
88 'src/_filesys.i',
89 'src/_gdicmn.i',
90 'src/_image.i',
91 'src/_menu.i',
92 'src/_obj.i',
93 'src/_sizers.i',
94 'src/_gbsizer.i',
95 'src/_streams.i',
96 'src/_validator.i',
97 'src/_window.i',
98 'src/_control.i',
99 ],
100 True)
101
102 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
103 CLEANUP.append(opj(PKGDIR, '__init__.py'))
104
105
106 # update the license files
107 mkpath('licence')
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')
112
113
114 if os.name == 'nt':
115 build_locale_dir(opj(PKGDIR, 'locale'))
116 DATA_FILES += build_locale_list(opj(PKGDIR, 'locale'))
117
118
119 if os.name == 'nt':
120 rc_file = ['src/wxc.rc']
121 else:
122 rc_file = []
123
124
125 ext = Extension('_core_', ['src/helpers.cpp',
126 'src/libpy.c',
127 ] + rc_file + swig_sources,
128
129 include_dirs = includes,
130 define_macros = defines,
131
132 library_dirs = libdirs,
133 libraries = libs,
134
135 extra_compile_args = cflags,
136 extra_link_args = lflags,
137
138 depends = depends
139 )
140 wxpExtensions.append(ext)
141
142
143
144
145
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',
150 'src/_bitmap.i',
151 'src/_colour.i',
152 'src/_dc.i',
153 'src/_gdiobj.i',
154 'src/_imaglist.i',
155 'src/_region.i',
156 'src/_stockobjs.i',
157 'src/_effects.i',
158 'src/_intl.i',
159 'src/_intl_ex.py',
160 'src/_brush.i',
161 'src/_cursor.i',
162 'src/_font.i',
163 'src/_icon.i',
164 'src/_pen.i',
165 'src/_palette.i',
166 ],
167 True)
168 ext = Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources,
169 include_dirs = includes,
170 define_macros = defines,
171 library_dirs = libdirs,
172 libraries = libs,
173 extra_compile_args = cflags,
174 extra_link_args = lflags,
175 depends = depends
176 )
177 wxpExtensions.append(ext)
178
179
180
181
182
183
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',
189 'src/_panel.i',
190 'src/_toplvl.i',
191 'src/_statusbar.i',
192 'src/_splitter.i',
193 'src/_sashwin.i',
194 'src/_popupwin.i',
195 'src/_tipwin.i',
196 'src/_vscroll.i',
197 'src/_taskbar.i',
198 'src/_cmndlgs.i',
199 'src/_mdi.i',
200 'src/_pywindows.i',
201 'src/_printfw.i',
202 ],
203 True)
204 ext = Extension('_windows_', swig_sources,
205 include_dirs = includes,
206 define_macros = defines,
207 library_dirs = libdirs,
208 libraries = libs,
209 extra_compile_args = cflags,
210 extra_link_args = lflags,
211 depends = depends
212 )
213 wxpExtensions.append(ext)
214
215
216
217
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',
223 'src/_toolbar.i',
224 'src/_button.i',
225 'src/_checkbox.i',
226 'src/_choice.i',
227 'src/_combobox.i',
228 'src/_gauge.i',
229 'src/_statctrls.i',
230 'src/_listbox.i',
231 'src/_textctrl.i',
232 'src/_scrolbar.i',
233 'src/_spin.i',
234 'src/_radio.i',
235 'src/_slider.i',
236 'src/_tglbtn.i',
237 'src/_notebook.i',
238 'src/_listctrl.i',
239 'src/_treectrl.i',
240 'src/_dirctrl.i',
241 'src/_pycontrol.i',
242 'src/_cshelp.i',
243 'src/_dragimg.i',
244 ],
245 True)
246 ext = Extension('_controls_', swig_sources,
247 include_dirs = includes,
248 define_macros = defines,
249 library_dirs = libdirs,
250 libraries = libs,
251 extra_compile_args = cflags,
252 extra_link_args = lflags,
253 depends = depends
254 )
255 wxpExtensions.append(ext)
256
257
258
259
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',
265 'src/_settings.i',
266 'src/_functions.i',
267 'src/_misc.i',
268 'src/_tipdlg.i',
269 'src/_timer.i',
270 'src/_log.i',
271 'src/_process.i',
272 'src/_joystick.i',
273 'src/_sound.i',
274 'src/_mimetype.i',
275 'src/_artprov.i',
276 'src/_config.i',
277 'src/_datetime.i',
278 'src/_dataobj.i',
279 'src/_dnd.i',
280 'src/_display.i',
281 'src/_clipbrd.i',
282 ],
283 True)
284 ext = Extension('_misc_', swig_sources,
285 include_dirs = includes,
286 define_macros = defines,
287 library_dirs = libdirs,
288 libraries = libs,
289 extra_compile_args = cflags,
290 extra_link_args = lflags,
291 depends = depends
292 )
293 wxpExtensions.append(ext)
294
295
296
297 ##
298 ## Core modules that are not in the "core" namespace start here
299 ##
300
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,
307 libraries = libs,
308 extra_compile_args = cflags,
309 extra_link_args = lflags,
310 depends = depends
311 )
312 wxpExtensions.append(ext)
313
314
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,
321 libraries = libs,
322 extra_compile_args = cflags,
323 extra_link_args = lflags,
324 depends = depends
325 )
326 wxpExtensions.append(ext)
327
328
329
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,
336 libraries = libs,
337 extra_compile_args = cflags,
338 extra_link_args = lflags,
339 depends = depends
340 )
341 wxpExtensions.append(ext)
342
343
344
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,
351 libraries = libs,
352 extra_compile_args = cflags,
353 extra_link_args = lflags,
354 depends = depends
355 )
356 wxpExtensions.append(ext)
357
358
359
360 swig_sources = run_swig(['xrc.i'], 'src', GENDIR, PKGDIR,
361 USE_SWIG, swig_force, swig_args, swig_deps +
362 [ 'src/_xrc_rename.i',
363 'src/_xrc_ex.py',
364 'src/_xmlres.i',
365 'src/_xmlsub.i',
366 'src/_xml.i',
367 'src/_xmlhandler.i',
368 ])
369 ext = Extension('_xrc',
370 swig_sources,
371
372 include_dirs = includes + CONTRIBS_INC,
373 define_macros = defines,
374
375 library_dirs = libdirs,
376 libraries = libs,
377
378 extra_compile_args = cflags,
379 extra_link_args = lflags,
380 )
381 wxpExtensions.append(ext)
382
383
384 #----------------------------------------------------------------------
385 # Define the GLCanvas extension module
386 #----------------------------------------------------------------------
387
388 if BUILD_GLCANVAS:
389 msg('Preparing GLCANVAS...')
390 location = 'contrib/glcanvas'
391
392 swig_sources = run_swig(['glcanvas.i'], location, GENDIR, PKGDIR,
393 USE_SWIG, swig_force, swig_args, swig_deps)
394
395 gl_libs = []
396 if os.name == 'posix':
397 gl_config = os.popen(WX_CONFIG + ' --libs gl', 'r').read()[:-1]
398 gl_lflags = gl_config.split() + lflags
399 gl_libs = libs
400 else:
401 gl_libs = libs + ['opengl32', 'glu32'] + makeLibName('gl')
402 gl_lflags = lflags
403
404 ext = Extension('_glcanvas',
405 swig_sources,
406
407 include_dirs = includes + CONTRIBS_INC,
408 define_macros = defines,
409
410 library_dirs = libdirs,
411 libraries = gl_libs,
412
413 extra_compile_args = cflags,
414 extra_link_args = gl_lflags,
415 )
416
417 wxpExtensions.append(ext)
418
419
420 #----------------------------------------------------------------------
421 # Define the OGL extension module
422 #----------------------------------------------------------------------
423
424 if BUILD_OGL:
425 msg('Preparing OGL...')
426 location = 'contrib/ogl'
427
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,
435 ])
436
437 ext = Extension('_ogl',
438 swig_sources,
439
440 include_dirs = includes + [ location ] + CONTRIBS_INC,
441 define_macros = defines + [('wxUSE_DEPRECATED', '0')],
442
443 library_dirs = libdirs,
444 libraries = libs + makeLibName('ogl'),
445
446 extra_compile_args = cflags,
447 extra_link_args = lflags,
448 )
449
450 wxpExtensions.append(ext)
451
452
453
454 #----------------------------------------------------------------------
455 # Define the STC extension module
456 #----------------------------------------------------------------------
457
458 if BUILD_STC:
459 msg('Preparing STC...')
460 location = 'contrib/stc'
461 if os.name == 'nt':
462 STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
463 else:
464 STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
465
466 ## NOTE: need to add something like this to the stc.bkl...
467
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'))):
472
473 ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...')
474 ## cwd = os.getcwd()
475 ## os.chdir(opj(CTRB_SRC, 'stc'))
476 ## sys.path.insert(0, os.curdir)
477 ## import gen_iface
478 ## gen_iface.main([])
479 ## os.chdir(cwd)
480
481
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)
486
487 ext = Extension('_stc',
488 swig_sources,
489
490 include_dirs = includes + CONTRIBS_INC,
491 define_macros = defines,
492
493 library_dirs = libdirs,
494 libraries = libs + makeLibName('stc'),
495
496 extra_compile_args = cflags,
497 extra_link_args = lflags,
498 )
499
500 wxpExtensions.append(ext)
501
502
503
504 #----------------------------------------------------------------------
505 # Define the IEWIN extension module (experimental)
506 #----------------------------------------------------------------------
507
508 if BUILD_IEWIN:
509 msg('Preparing IEWIN...')
510 location = 'contrib/iewin'
511
512 swig_files = ['iewin.i', ]
513
514 swig_sources = run_swig(swig_files, location, '', PKGDIR,
515 USE_SWIG, swig_force, swig_args, swig_deps)
516
517
518 ext = Extension('_iewin', ['%s/IEHtmlWin.cpp' % location,
519 '%s/wxactivex.cpp' % location,
520 ] + swig_sources,
521
522 include_dirs = includes + CONTRIBS_INC,
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 ACTIVEX extension module (experimental)
537 #----------------------------------------------------------------------
538
539 if BUILD_ACTIVEX:
540 msg('Preparing ACTIVEX...')
541 location = 'contrib/activex'
542 axloc = opj(location, "wxie")
543
544 swig_files = ['activex.i', ]
545
546 swig_sources = run_swig(swig_files, location, '', PKGDIR,
547 USE_SWIG, swig_force, swig_args, swig_deps +
548 [ '%s/_activex_ex.py' % location])
549
550
551 ext = Extension('_activex', ['%s/IEHtmlWin.cpp' % axloc,
552 '%s/wxactivex.cpp' % axloc,
553 ] + swig_sources,
554
555 include_dirs = includes + [ axloc ],
556 define_macros = defines,
557
558 library_dirs = libdirs,
559 libraries = libs,
560
561 extra_compile_args = cflags,
562 extra_link_args = lflags,
563 )
564
565 wxpExtensions.append(ext)
566
567
568 #----------------------------------------------------------------------
569 # Define the GIZMOS extension module
570 #----------------------------------------------------------------------
571
572 if BUILD_GIZMOS:
573 msg('Preparing GIZMOS...')
574 location = 'contrib/gizmos'
575
576 swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR,
577 USE_SWIG, swig_force, swig_args, swig_deps)
578
579 ext = Extension('_gizmos',
580 [ '%s/treelistctrl.cpp' % opj(location, 'wxCode/src') ] + swig_sources,
581
582 include_dirs = includes + [ location, opj(location, 'wxCode/include') ] + CONTRIBS_INC,
583 define_macros = defines,
584
585 library_dirs = libdirs,
586 libraries = libs + makeLibName('gizmos'),
587
588 extra_compile_args = cflags,
589 extra_link_args = lflags,
590 )
591
592 wxpExtensions.append(ext)
593
594
595
596 #----------------------------------------------------------------------
597 # Define the DLLWIDGET extension module
598 #----------------------------------------------------------------------
599
600 if BUILD_DLLWIDGET:
601 msg('Preparing DLLWIDGET...')
602 location = 'contrib/dllwidget'
603 swig_files = ['dllwidget_.i']
604
605 swig_sources = run_swig(swig_files, location, '', PKGDIR,
606 USE_SWIG, swig_force, swig_args, swig_deps)
607
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'))
611
612 ext = Extension('dllwidget_c', [
613 '%s/dllwidget.cpp' % location,
614 ] + swig_sources,
615
616 include_dirs = includes + CONTRIBS_INC,
617 define_macros = defines,
618
619 library_dirs = libdirs,
620 libraries = libs,
621
622 extra_compile_args = cflags,
623 extra_link_args = lflags,
624 )
625
626 wxpExtensions.append(ext)
627
628
629
630 #----------------------------------------------------------------------
631 # patch distutils if it can't cope with the "classifiers" or
632 # "download_url" keywords
633 #----------------------------------------------------------------------
634
635 if sys.version < '2.2.3':
636 from distutils.dist import DistributionMetadata
637 DistributionMetadata.classifiers = None
638 DistributionMetadata.download_url = None
639
640
641 #----------------------------------------------------------------------
642 # Tools, scripts data files, etc.
643 #----------------------------------------------------------------------
644
645 if NO_SCRIPTS:
646 SCRIPTS = None
647 else:
648 SCRIPTS = [opj('scripts/helpviewer'),
649 opj('scripts/img2png'),
650 opj('scripts/img2xpm'),
651 opj('scripts/img2py'),
652 opj('scripts/xrced'),
653 opj('scripts/pyshell'),
654 opj('scripts/pycrust'),
655 opj('scripts/pywrap'),
656 opj('scripts/pywrap'),
657 opj('scripts/pyalacarte'),
658 opj('scripts/pyalamode'),
659 ]
660
661
662 DATA_FILES += find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
663 DATA_FILES += find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
664 DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html')
665
666
667 if NO_HEADERS:
668 HEADERS = None
669 else:
670 h_files = glob.glob(opj("include/wx/wxPython/*.h"))
671 i_files = glob.glob(opj("src/*.i")) + \
672 glob.glob(opj("src/_*.py")) + \
673 glob.glob(opj("src/*.swg"))
674
675 HEADERS = zip(h_files, ["/wxPython"]*len(h_files)) + \
676 zip(i_files, ["/wxPython/i_files"]*len(i_files))
677
678
679 #----------------------------------------------------------------------
680 # Do the Setup/Build/Install/Whatever
681 #----------------------------------------------------------------------
682
683 if __name__ == "__main__":
684 if not PREP_ONLY:
685 setup(name = 'wxPython',
686 version = VERSION,
687 description = DESCRIPTION,
688 long_description = LONG_DESCRIPTION,
689 author = AUTHOR,
690 author_email = AUTHOR_EMAIL,
691 url = URL,
692 download_url = DOWNLOAD_URL,
693 license = LICENSE,
694 platforms = PLATFORMS,
695 classifiers = filter(None, CLASSIFIERS.split("\n")),
696 keywords = KEYWORDS,
697
698 packages = ['wxPython',
699 'wxPython.lib',
700 'wxPython.lib.colourchooser',
701 'wxPython.lib.editor',
702 'wxPython.lib.mixins',
703 'wxPython.tools',
704
705 'wx',
706 'wx.build',
707 'wx.lib',
708 'wx.lib.colourchooser',
709 'wx.lib.editor',
710 'wx.lib.floatcanvas',
711 'wx.lib.masked',
712 'wx.lib.mixins',
713 'wx.lib.ogl',
714 'wx.py',
715 'wx.tools',
716 'wx.tools.XRCed',
717 ],
718
719 ext_package = PKGDIR,
720 ext_modules = wxpExtensions,
721
722 options = { 'build' : { 'build_base' : BUILD_BASE },
723 },
724
725 scripts = SCRIPTS,
726 data_files = DATA_FILES,
727 headers = HEADERS,
728
729 cmdclass = { 'install_data': wx_smart_install_data,
730 'install_headers': wx_install_headers,
731 'clean': wx_extra_clean,
732 },
733 )
734
735
736 #----------------------------------------------------------------------
737 #----------------------------------------------------------------------