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