]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
Added support more support for DB2
[wxWidgets.git] / wxPython / setup.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------
3
4 import sys, os, string
5 from distutils.core import setup, Extension
6 from distutils.file_util import copy_file
7 from distutils.dir_util import mkpath
8 from distutils.dep_util import newer
9
10 from my_distutils import run_swig, contrib_copy_tree
11
12 #----------------------------------------------------------------------
13 # flags and values that affect this script
14 #----------------------------------------------------------------------
15
16 VERSION = "2.3b4"
17 DESCRIPTION = "Cross platform GUI toolkit for Python"
18 AUTHOR = "Robin Dunn"
19 AUTHOR_EMAIL = "robin@alldunn.com"
20 URL = "http://wxPython.org/"
21 LICENCE = "wxWindows (LGPL derivative)"
22 LONG_DESCRIPTION = """\
23 wxPython is a GUI toolkit for Python that is a wrapper around the
24 wxWindows C++ GUI library. wxPython provides a large variety of
25 window types and controls, all implemented with a native look and
26 feel (and native runtime speed) on the platforms it is supported
27 on.
28 """
29
30
31 BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module
32 BUILD_OGL = 1 # If true, build the contrib/ogl extension module
33 BUILD_STC = 1 # If true, build the contrib/stc extension module
34 BUILD_IEWIN = 0 # Internet Explorer wrapper (experimental)
35
36 CORE_ONLY = 0 # if true, don't build any of the above
37 GL_ONLY = 0 # Only used when making the -gl RPM. See the "b" script
38 # for the ugly details
39
40 USE_SWIG = 0 # Should we actually execute SWIG, or just use the
41 # files already in the distribution?
42
43 IN_CVS_TREE = 0 # Set to true if building in a full wxWindows CVS
44 # tree, otherwise will assume all needed files are
45 # available in the wxPython source distribution
46
47 WX_CONFIG = "wx-config" # Usually you shouldn't need to touch this,
48 # but you can set it to pass an alternate
49 # version of wx-config or alternate flags,
50 # eg. as required by the .deb in-tree build.
51
52 # Some MSW build settings
53
54 FINAL = 1 # Mirrors use of same flag in wx makefiles,
55 # (0 or 1 only) should probably find a way to
56 # autodetect this...
57
58 HYBRID = 0 # If set and not debug or FINAL, then build a
59 # hybrid extension that can be used by the
60 # non-debug version of python, but contains
61 # debugging symbols for wxWindows and wxPython.
62 # wxWindows must have been built with /MD, not /MDd
63 # (using FINAL=hybrid will do it.)
64
65 WXDLLVER = '23_0' # Version part of DLL name
66
67
68 #----------------------------------------------------------------------
69 # Some other globals
70 #----------------------------------------------------------------------
71
72 PKGDIR = 'wxPython'
73 wxpExtensions = []
74
75 force = '--force' in sys.argv or '-f' in sys.argv
76 debug = '--debug' in sys.argv or '-g' in sys.argv
77
78 bcpp_compiling = '-c' in sys.argv and 'my_bcpp' in sys.argv # Bad heuristic
79
80 if bcpp_compiling:
81 print "Compiling wxPython by Borland C/C++ Compiler"
82 HYBRID=0
83 WXBCPPLIBVER = string.replace(WXDLLVER,"_","")
84 # Version part of BCPP build LIBRARY name
85 WXDLLVER="" # no dll ver path avaible
86
87
88 #----------------------------------------------------------------------
89 # Check for build flags on the command line
90 #----------------------------------------------------------------------
91
92 for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
93 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID', ]:
94 for x in range(len(sys.argv)):
95 if string.find(sys.argv[x], flag) == 0:
96 pos = string.find(sys.argv[x], '=') + 1
97 if pos > 0:
98 vars()[flag] = eval(sys.argv[x][pos:])
99 sys.argv[x] = ''
100
101 for option in ['WX_CONFIG', 'WXDLLVER', ]:
102 for x in range(len(sys.argv)):
103 if string.find(sys.argv[x], option) == 0:
104 pos = string.find(sys.argv[x], '=') + 1
105 if pos > 0:
106 vars()[option] = sys.argv[x][pos:]
107 sys.argv[x] = ''
108
109 sys.argv = filter(None, sys.argv)
110
111
112 if CORE_ONLY:
113 BUILD_GLCANVAS = 0
114 BUILD_OGL = 0
115 BUILD_STC = 0
116
117 #----------------------------------------------------------------------
118 # Setup some platform specific stuff
119 #----------------------------------------------------------------------
120
121 if os.name == 'nt':
122 # Set compile flags and such for MSVC. These values are derived
123 # from the wxWindows makefiles for MSVC, others will probably
124 # vary...
125 WXDIR = os.environ['WXWIN']
126 WXPLAT = '__WXMSW__'
127 GENDIR = 'msw'
128
129 if debug:
130 FINAL = 0
131 HYBRID = 0
132
133 if HYBRID:
134 FINAL = 0
135
136 includes = ['src',
137 os.path.join(WXDIR, 'include'),
138 ]
139
140 defines = [ ('WIN32', None), # Some of these are no longer
141 ('__WIN32__', None), # necessary. Anybody know which?
142 ('_WINDOWS', None),
143 ('__WINDOWS__', None),
144 ('WINVER', '0x0400'),
145 ('__WIN95__', None),
146 ('STRICT', None),
147
148 (WXPLAT, None),
149 ('WXUSINGDLL', '1'),
150
151 ('SWIG_GLOBAL', None),
152 ('HAVE_CONFIG_H', None),
153 ('WXP_USE_THREAD', '1'),
154 ]
155
156 if bcpp_compiling: # overwrite it
157 defines = [
158 ('_WINDOWS', None),
159 ('WINVER', '0x0400'),
160 ('STRICT', None),
161
162 ('WXUSINGDLL', '1'),
163
164 ('SWIG_GLOBAL', None),
165 ('HAVE_CONFIG_H', None),
166 ('WXP_USE_THREAD', '1'),
167
168 ('WXUSE_DEFINE','1'),
169 ('_RTLDLL',None),
170 ]
171
172
173 if not FINAL or HYBRID:
174 defines.append( ('__WXDEBUG__', None) )
175
176 libdirs = [os.path.join(WXDIR, 'lib'), 'build\\ilib']
177
178 if FINAL:
179 wxdll = 'wx' + WXDLLVER
180 elif HYBRID:
181 wxdll = 'wx' + WXDLLVER + 'h'
182 else:
183 wxdll = 'wx' + WXDLLVER + 'd'
184
185
186 libs = [wxdll]
187 if bcpp_compiling:
188 libs = ['wx'+WXBCPPLIBVER]
189
190 libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
191 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
192 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
193 'advapi32', 'wsock32']
194
195
196 cflags = [] #['/GX-'] # workaround for internal compiler error in MSVC 5
197 lflags = None
198
199
200 if bcpp_compiling: # overwrite it
201 cflags = ['-5', '-VF', ### To supplort MSVC spurious semicolons in the class scope
202 ### else, all semicolons at the end of all DECLARE_...CALLBACK... macros must be eliminated
203 '-Hc', '-H='+WXDIR+'\src\msw\wx32.csm',
204 '@'+WXDIR+'\src\msw\wxwin32.cfg'
205 ]
206
207
208 if not FINAL and HYBRID and not bcpp_compiling:
209 cflags = cflags + ['/Od', '/Z7']
210 lflags = ['/DEBUG', ]
211
212 elif bcpp_compiling and not FINAL:
213 cflags = cflags + ['/Od', '/v', '/y']
214 lflags = lflags + ['/v', ] ## '/PDB:NONE']
215
216
217
218 elif os.name == 'posix':
219 # Set flags for Unix type platforms
220
221 WXDIR = '..' # assumes IN_CVS_TREE
222 WXPLAT = '__WXGTK__' # and assumes GTK...
223 GENDIR = 'gtk' # Need to allow for Motif eventually too
224
225 includes = ['src']
226 defines = [('SWIG_GLOBAL', None),
227 ('HAVE_CONFIG_H', None),
228 ('WXP_USE_THREAD', '1'),
229 ]
230 libdirs = []
231 libs = []
232
233 cflags = os.popen(WX_CONFIG + ' --cflags', 'r').read()[:-1] + ' ' + \
234 os.popen('gtk-config --cflags', 'r').read()[:-1]
235 cflags = string.split(cflags)
236
237 lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1]
238 lflags = string.split(lflags)
239
240
241 else:
242 raise 'Sorry Charlie...'
243
244
245 #----------------------------------------------------------------------
246 # Check if the version file needs updated
247 #----------------------------------------------------------------------
248
249 if IN_CVS_TREE and newer('setup.py', 'src/__version__.py'):
250 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION)
251
252
253
254 #----------------------------------------------------------------------
255 # SWIG defaults
256 #----------------------------------------------------------------------
257
258 swig_force = force
259 swig_args = ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
260 '-I./src', '-D'+WXPLAT]
261 swig_deps = ['src/my_typemaps.i']
262
263
264 #----------------------------------------------------------------------
265 # Define the CORE extension module
266 #----------------------------------------------------------------------
267
268 if not GL_ONLY:
269 print 'Preparing CORE...'
270 swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
271 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
272 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
273 'printfw.i', 'sizers.i', 'clip_dnd.i',
274 'filesys.i', 'streams.i',
275 ##'grid.i', 'html.i', 'htmlhelp.i', 'calendar.i', 'utils.i',
276 ]
277
278 swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
279 USE_SWIG, swig_force, swig_args, swig_deps)
280
281 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
282 copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
283
284
285 if IN_CVS_TREE: # update the licence files
286 mkpath('licence')
287 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
288 copy_file(WXDIR+'/docs/'+file, 'licence/'+file, update=1, verbose=0)
289
290
291 if os.name == 'nt':
292 rc_file = ['src/wxc.rc']
293 else:
294 rc_file = []
295
296
297 ext = Extension('wxc', ['src/helpers.cpp',
298 'src/libpy.c',
299 ] + rc_file + swig_sources,
300
301 include_dirs = includes,
302 define_macros = defines,
303
304 library_dirs = libdirs,
305 libraries = libs,
306
307 extra_compile_args = cflags,
308 extra_link_args = lflags,
309 )
310 wxpExtensions.append(ext)
311
312
313 # Extension for the grid module
314 swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR,
315 USE_SWIG, swig_force, swig_args, swig_deps)
316 ext = Extension('gridc', 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 )
324 wxpExtensions.append(ext)
325
326
327 # Extension for the html modules
328 swig_sources = run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR, PKGDIR,
329 USE_SWIG, swig_force, swig_args, swig_deps)
330 ext = Extension('htmlc', swig_sources,
331 include_dirs = includes,
332 define_macros = defines,
333 library_dirs = libdirs,
334 libraries = libs,
335 extra_compile_args = cflags,
336 extra_link_args = lflags,
337 )
338 wxpExtensions.append(ext)
339
340
341 # Extension for the utils module
342 swig_sources = run_swig(['utils.i'], 'src', GENDIR, PKGDIR,
343 USE_SWIG, swig_force, swig_args, swig_deps)
344 ext = Extension('utilsc', swig_sources,
345 include_dirs = includes,
346 define_macros = defines,
347 library_dirs = libdirs,
348 libraries = libs,
349 extra_compile_args = cflags,
350 extra_link_args = lflags,
351 )
352 wxpExtensions.append(ext)
353
354
355 # Extension for the calendar module
356 swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR,
357 USE_SWIG, swig_force, swig_args, swig_deps)
358 ext = Extension('calendarc', swig_sources,
359 include_dirs = includes,
360 define_macros = defines,
361 library_dirs = libdirs,
362 libraries = libs,
363 extra_compile_args = cflags,
364 extra_link_args = lflags,
365 )
366 wxpExtensions.append(ext)
367
368
369 #----------------------------------------------------------------------
370 # Define the GLCanvas extension module
371 #----------------------------------------------------------------------
372
373 if BUILD_GLCANVAS or GL_ONLY:
374 print 'Preparing GLCANVAS...'
375 location = 'contrib/glcanvas'
376 swig_files = ['glcanvas.i']
377 other_sources = []
378
379 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
380 USE_SWIG, swig_force, swig_args)
381
382 gl_libs = []
383 if os.name == 'posix':
384 if '-D__WXDEBUG__' in cflags:
385 gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
386 else:
387 gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
388 else:
389 other_sources = [location + '/msw/myglcanvas.cpp']
390 gl_libs = ['opengl32', 'glu32']
391
392
393 ext = Extension('glcanvasc',
394 swig_sources + other_sources,
395
396 include_dirs = includes,
397 define_macros = defines,
398
399 library_dirs = libdirs,
400 libraries = libs + gl_libs,
401
402 extra_compile_args = cflags,
403 extra_link_args = lflags,
404 )
405
406 wxpExtensions.append(ext)
407
408
409 #----------------------------------------------------------------------
410 # Define the OGL extension module
411 #----------------------------------------------------------------------
412
413 if not GL_ONLY and BUILD_OGL:
414 print 'Preparing OGL...'
415 location = 'contrib/ogl'
416 OGLLOC = location + '/contrib/src/ogl'
417 OGLINC = location + '/contrib/include'
418
419 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
420 'oglcanvas.i']
421
422 swig_sources = run_swig(swig_files, location, '', PKGDIR,
423 USE_SWIG, swig_force, swig_args)
424
425 # make sure local copy of contrib files are up to date
426 if IN_CVS_TREE:
427 contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
428 contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
429
430 ext = Extension('oglc', ['%s/basic.cpp' % OGLLOC,
431 '%s/bmpshape.cpp' % OGLLOC,
432 '%s/composit.cpp' % OGLLOC,
433 '%s/divided.cpp' % OGLLOC,
434 '%s/lines.cpp' % OGLLOC,
435 '%s/misc.cpp' % OGLLOC,
436 '%s/basic2.cpp' % OGLLOC,
437 '%s/canvas.cpp' % OGLLOC,
438 '%s/constrnt.cpp' % OGLLOC,
439 '%s/drawn.cpp' % OGLLOC,
440 '%s/mfutils.cpp' % OGLLOC,
441 '%s/ogldiag.cpp' % OGLLOC,
442 ] + swig_sources,
443
444 include_dirs = [OGLINC] + includes,
445 define_macros = defines,
446
447 library_dirs = libdirs,
448 libraries = libs,
449
450 extra_compile_args = cflags,
451 extra_link_args = lflags,
452 )
453
454 wxpExtensions.append(ext)
455
456
457
458 #----------------------------------------------------------------------
459 # Define the STC extension module
460 #----------------------------------------------------------------------
461
462 if not GL_ONLY and BUILD_STC:
463 print 'Preparing STC...'
464 location = 'contrib/stc'
465 STCLOC = location + '/contrib/src/stc'
466 STCINC = location + '/contrib/include'
467 STC_H = location + '/contrib/include/wx/stc'
468
469 # make sure local copy of contrib files are up to date
470 if IN_CVS_TREE:
471 contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
472 contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
473
474
475 swig_files = ['stc_.i']
476 swig_sources = run_swig(swig_files, location, '', PKGDIR,
477 USE_SWIG, swig_force,
478 swig_args + ['-I'+STC_H, '-I'+location],
479 [STC_H+'/stc.h'])
480
481 # copy a project specific py module to the main package dir
482 copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
483
484 # add some include dirs to the standard set
485 stc_includes = includes[:]
486 stc_includes.append('%s/scintilla/include' % STCLOC)
487 stc_includes.append('%s/scintilla/src' % STCLOC)
488 stc_includes.append(STCINC)
489
490 # and some macro definitions
491 stc_defines = defines[:]
492 stc_defines.append( ('__WX__', None) )
493 stc_defines.append( ('SCI_LEXER', None) )
494
495
496 ext = Extension('stc_c',
497 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
498 '%s/scintilla/src/CallTip.cxx' % STCLOC,
499 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
500 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
501 '%s/scintilla/src/Document.cxx' % STCLOC,
502 '%s/scintilla/src/Editor.cxx' % STCLOC,
503 '%s/scintilla/src/Indicator.cxx' % STCLOC,
504 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
505 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
506 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
507 '%s/scintilla/src/PropSet.cxx' % STCLOC,
508 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
509 '%s/scintilla/src/Style.cxx' % STCLOC,
510 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
511 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
512 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
513 '%s/scintilla/src/LexLua.cxx' % STCLOC,
514 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
515 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
516 '%s/scintilla/src/LexPython.cxx' % STCLOC,
517 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
518 '%s/scintilla/src/LexVB.cxx' % STCLOC,
519 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
520 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
521 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
522 '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
523
524 '%s/PlatWX.cpp' % STCLOC,
525 '%s/ScintillaWX.cpp' % STCLOC,
526 '%s/stc.cpp' % STCLOC,
527 ] + swig_sources,
528
529 include_dirs = stc_includes,
530 define_macros = stc_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 #----------------------------------------------------------------------
544 # Define the IEWIN extension module (experimental)
545 #----------------------------------------------------------------------
546
547 if not GL_ONLY and BUILD_IEWIN:
548 print 'Preparing IEWIN...'
549 location = 'contrib/iewin'
550
551 swig_files = ['iewin.i', ]
552
553 swig_sources = run_swig(swig_files, location, '', PKGDIR,
554 USE_SWIG, swig_force, swig_args)
555
556
557 ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location,
558 ] + swig_sources,
559
560 include_dirs = includes,
561 define_macros = defines,
562
563 library_dirs = libdirs,
564 libraries = libs,
565
566 extra_compile_args = cflags,
567 extra_link_args = lflags,
568 )
569
570 wxpExtensions.append(ext)
571
572
573
574 #----------------------------------------------------------------------
575 # Do the Setup/Build/Install/Whatever
576 #----------------------------------------------------------------------
577
578 if __name__ == "__main__":
579 if not GL_ONLY:
580 setup(name = PKGDIR,
581 version = VERSION,
582 description = DESCRIPTION,
583 long_description = LONG_DESCRIPTION,
584 author = AUTHOR,
585 author_email = AUTHOR_EMAIL,
586 url = URL,
587 licence = LICENCE,
588
589 packages = [PKGDIR,
590 PKGDIR+'.lib',
591 PKGDIR+'.lib.editor',
592 ],
593
594 ext_package = PKGDIR,
595 ext_modules = wxpExtensions,
596 )
597
598 else:
599
600 setup(name = "wxPython-gl",
601 version = VERSION,
602 description = "wxGLCanvas class for wxPython",
603 author = AUTHOR,
604 author_email = AUTHOR_EMAIL,
605 url = URL,
606 licence = LICENCE,
607
608 py_modules = [ "wxPython.glcanvas" ],
609
610 ext_package = PKGDIR,
611 ext_modules = wxpExtensions,
612 )
613
614
615
616
617 #----------------------------------------------------------------------
618 #----------------------------------------------------------------------