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