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