]> git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
fixed typo in a couple method names for wxPython, also some changes in
[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 other_sources = []
331
332 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
333 USE_SWIG, swig_force, swig_args)
334
335 gl_libs = []
336 if os.name == 'posix':
337 if '-D__WXDEBUG__' in cflags:
338 gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
339 else:
340 gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
341 else:
342 other_sources = [location + '/msw/myglcanvas.cpp']
343 gl_libs = ['opengl32', 'glu32']
344
345
346 ext = Extension('glcanvasc',
347 swig_sources + other_sources,
348
349 include_dirs = includes,
350 define_macros = defines,
351
352 library_dirs = libdirs,
353 libraries = libs + gl_libs,
354
355 extra_compile_args = cflags,
356 extra_link_args = lflags,
357 )
358
359 wxpExtensions.append(ext)
360
361
362 #----------------------------------------------------------------------
363 # Define the OGL extension module
364 #----------------------------------------------------------------------
365
366 if not GL_ONLY and BUILD_OGL:
367 print 'Preparing OGL...'
368 location = 'contrib/ogl'
369 OGLLOC = location + '/contrib/src/ogl'
370 OGLINC = location + '/contrib/include'
371
372 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
373 'oglcanvas.i']
374
375 swig_sources = run_swig(swig_files, location, '', PKGDIR,
376 USE_SWIG, swig_force, swig_args)
377
378 # make sure local copy of contrib files are up to date
379 if IN_CVS_TREE:
380 contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
381 contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
382
383 ext = Extension('oglc', ['%s/basic.cpp' % OGLLOC,
384 '%s/bmpshape.cpp' % OGLLOC,
385 '%s/composit.cpp' % OGLLOC,
386 '%s/divided.cpp' % OGLLOC,
387 '%s/lines.cpp' % OGLLOC,
388 '%s/misc.cpp' % OGLLOC,
389 '%s/basic2.cpp' % OGLLOC,
390 '%s/canvas.cpp' % OGLLOC,
391 '%s/constrnt.cpp' % OGLLOC,
392 '%s/drawn.cpp' % OGLLOC,
393 '%s/mfutils.cpp' % OGLLOC,
394 '%s/ogldiag.cpp' % OGLLOC,
395 ] + swig_sources,
396
397 include_dirs = [OGLINC] + includes,
398 define_macros = defines,
399
400 library_dirs = libdirs,
401 libraries = libs,
402
403 extra_compile_args = cflags,
404 extra_link_args = lflags,
405 )
406
407 wxpExtensions.append(ext)
408
409
410
411 #----------------------------------------------------------------------
412 # Define the STC extension module
413 #----------------------------------------------------------------------
414
415 if not GL_ONLY and BUILD_STC:
416 print 'Preparing STC...'
417 location = 'contrib/stc'
418 STCLOC = location + '/contrib/src/stc'
419 STCINC = location + '/contrib/include'
420 STC_H = location + '/contrib/include/wx/stc'
421
422 # make sure local copy of contrib files are up to date
423 if IN_CVS_TREE:
424 contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
425 contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
426
427
428 swig_files = ['stc_.i']
429 swig_sources = run_swig(swig_files, location, '', PKGDIR,
430 USE_SWIG, swig_force,
431 swig_args + ['-I'+STC_H, '-I'+location],
432 [STC_H+'/stc.h'])
433
434 # copy a project specific py module to the main package dir
435 copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
436
437 # add some include dirs to the standard set
438 stc_includes = includes[:]
439 stc_includes.append('%s/scintilla/include' % STCLOC)
440 stc_includes.append('%s/scintilla/src' % STCLOC)
441 stc_includes.append(STCINC)
442
443 # and some macro definitions
444 stc_defines = defines[:]
445 stc_defines.append( ('__WX__', None) )
446 stc_defines.append( ('SCI_LEXER', None) )
447
448
449 ext = Extension('stc_c',
450 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
451 '%s/scintilla/src/CallTip.cxx' % STCLOC,
452 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
453 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
454 '%s/scintilla/src/Document.cxx' % STCLOC,
455 '%s/scintilla/src/Editor.cxx' % STCLOC,
456 '%s/scintilla/src/Indicator.cxx' % STCLOC,
457 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
458 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
459 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
460 '%s/scintilla/src/PropSet.cxx' % STCLOC,
461 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
462 '%s/scintilla/src/Style.cxx' % STCLOC,
463 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
464 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
465 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
466 '%s/scintilla/src/LexLua.cxx' % STCLOC,
467 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
468 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
469 '%s/scintilla/src/LexPython.cxx' % STCLOC,
470 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
471 '%s/scintilla/src/LexVB.cxx' % STCLOC,
472 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
473 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
474 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
475 '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
476
477 '%s/PlatWX.cpp' % STCLOC,
478 '%s/ScintillaWX.cpp' % STCLOC,
479 '%s/stc.cpp' % STCLOC,
480 ] + swig_sources,
481
482 include_dirs = stc_includes,
483 define_macros = stc_defines,
484
485 library_dirs = libdirs,
486 libraries = libs,
487
488 extra_compile_args = cflags,
489 extra_link_args = lflags,
490 )
491
492 wxpExtensions.append(ext)
493
494
495
496 #----------------------------------------------------------------------
497 # Do the Setup/Build/Install/Whatever
498 #----------------------------------------------------------------------
499
500 if __name__ == "__main__":
501 if not GL_ONLY:
502 setup(name = PKGDIR,
503 version = VERSION,
504 description = DESCRIPTION,
505 long_description = LONG_DESCRIPTION,
506 author = AUTHOR,
507 author_email = AUTHOR_EMAIL,
508 url = URL,
509 licence = LICENCE,
510
511 packages = [PKGDIR,
512 PKGDIR+'.lib',
513 PKGDIR+'.lib.editor',
514 ],
515
516 ext_package = PKGDIR,
517 ext_modules = wxpExtensions,
518 )
519
520 else:
521
522 setup(name = "wxPython-gl",
523 version = VERSION,
524 description = "wxGLCanvas class for wxPython",
525 author = AUTHOR,
526 author_email = AUTHOR_EMAIL,
527 url = URL,
528 licence = LICENCE,
529
530 py_modules = [ "wxPython.glcanvas" ],
531
532 ext_package = PKGDIR,
533 ext_modules = wxpExtensions,
534 )
535
536
537
538
539 #----------------------------------------------------------------------
540 #----------------------------------------------------------------------