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