]> git.saurik.com Git - wxWidgets.git/blame - wxPython/setup.py
updated files to know about darwin (Mac OS X)
[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
16VERSION = "2.3.0b1"
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 imlemented 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
35
36USE_SWIG = 0 # Should we actually execute SWIG, or just use the
37 # files already in the distribution?
38
39IN_CVS_TREE = 0 # Set to true if building in a full wxWindows CVS
40 # tree, otherwise will assume all needed files are
41 # available in the wxPython source distribution
42
43
44# Some MSW build settings
45
46FINAL = 1 # Mirrors use of same flag in wx makefiles,
47 # (0 or 1 only) should probably find a way to
48 # autodetect this...
49
50HYBRID = 0 # If set and not debug or FINAL, then build a
51 # hybrid extension that can be used by the
52 # non-debug version of python, but contains
53 # debugging symbols for wxWindows and wxPython.
54 # wxWindows must have been built with /MD, not /MDd
55 # (using FINAL=hybrid will do it.)
56
57WXDLLVER = '23_0' # Version part of DLL name
58
59
60#----------------------------------------------------------------------
61# Some other globals
62#----------------------------------------------------------------------
63
64PKGDIR = 'wxPython'
65wxpExtensions = []
66
67force = '--force' in sys.argv or '-f' in sys.argv
68debug = '--debug' in sys.argv or '-g' in sys.argv
69
70
71#----------------------------------------------------------------------
72# Check for build flags on the command line
73#----------------------------------------------------------------------
74
75for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
76 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID',
77 'WXDLLVER', ]:
78 for x in range(len(sys.argv)):
79 if string.find(sys.argv[x], flag) == 0:
80 pos = string.find(sys.argv[x], '=') + 1
81 if pos > 0:
82 vars()[flag] = eval(sys.argv[x][pos:])
83 sys.argv[x] = ''
84
85sys.argv = filter(None, sys.argv)
86
87
88if CORE_ONLY:
89 BUILD_GLCANVAS = 0
90 BUILD_OGL = 0
91 BUILD_STC = 0
92
93#----------------------------------------------------------------------
94# Setup some platform specific stuff
95#----------------------------------------------------------------------
96
97if os.name == 'nt':
98 # Set compile flags and such for MSVC. These values are derived
99 # from the wxWindows makefiles for MSVC, others will probably
100 # vary...
101 WXDIR = os.environ['WXWIN']
102 WXPLAT = '__WXMSW__'
103 GENDIR = 'msw'
104
105
106
107 if debug:
108 FINAL = 0
109 HYBRID = 0
110
111 if HYBRID:
112 FINAL = 0
113
114
115 includes = ['src',
116 os.path.join(WXDIR, 'include'),
117 ]
118
119 defines = [ ('WIN32', None), # Some of these are no longer
120 ('__WIN32__', None), # necessary. Anybody know which?
121 ('_WINDOWS', None),
122 ('__WINDOWS__', None),
123 ('WINVER', '0x0400'),
124 ('__WIN95__', None),
125 ('STRICT', None),
126
127 (WXPLAT, None),
128 ('WXUSINGDLL', '1'),
129
130 ('SWIG_GLOBAL', None),
131 ('HAVE_CONFIG_H', None),
132 ('WXP_USE_THREAD', '1'),
133 ]
134
135 if not FINAL or HYBRID:
136 defines.append( ('__WXDEBUG__', None) )
137
138 libdirs = [os.path.join(WXDIR, 'lib'), 'build\\ilib']
139
140 if FINAL:
141 wxdll = 'wx' + WXDLLVER
142 elif HYBRID:
143 wxdll = 'wx' + WXDLLVER + 'h'
144 else:
145 wxdll = 'wx' + WXDLLVER + 'd'
146
147 #print 'Linking with ', wxdll
148
149 libs = [wxdll, 'kernel32', 'user32', 'gdi32', 'comdlg32',
150 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
151 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
152 'advapi32', 'wsock32']
153
e7d63784 154 cflags = ['/GX-'] # workaround for internal compiler error in MSVC
c368d904
RD
155 lflags = None
156
157 if not FINAL and HYBRID:
e7d63784
RD
158 cflags = cflags + ['/Od', '/Z7']
159 lflags = ['/DEBUG', ]
c368d904
RD
160
161
162elif os.name == 'posix':
163 # Set flags for Unix type platforms
164
165 WXDIR = '..' # assumes IN_CVS_TREE
166 WXPLAT = '__WXGTK__' # and assumes GTK...
167 GENDIR = 'gtk' # Need to allow for Motif eventually too
168
169 includes = ['src']
170 defines = [('SWIG_GLOBAL', None),
171 ('HAVE_CONFIG_H', None),
172 ('WXP_USE_THREAD', '1'),
173 ]
174 libdirs = []
175 libs = []
176
177 cflags = os.popen('wx-config --cflags', 'r').read()[:-1] + ' ' + \
178 os.popen('gtk-config --cflags', 'r').read()[:-1]
179 cflags = string.split(cflags)
180
181 lflags = os.popen('wx-config --libs', 'r').read()[:-1]
182 lflags = string.split(lflags)
183
184
185else:
186 raise 'Sorry Charlie...'
187
188
189#----------------------------------------------------------------------
190# Check if the version file needs updated
191#----------------------------------------------------------------------
192
193if IN_CVS_TREE and newer('setup.py', 'src/__version__.py'):
194 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION)
195
196#----------------------------------------------------------------------
197# Define the CORE extension module
198#----------------------------------------------------------------------
199
200print 'Preparing CORE...'
201swig_force = force
e7d63784 202swig_args = ['-c++', '-shadow', '-python', '-keyword', '-dascii',
c368d904
RD
203 '-I./src', '-D'+WXPLAT]
204
205swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
206 'misc.i', 'misc2.i', 'utils.i', 'gdi.i', 'mdi.i', 'controls.i',
207 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
208 'printfw.i', 'sizers.i', 'clip_dnd.i', 'grid.i', 'html.i',
209 'htmlhelp.i', 'calendar.i', 'filesys.i', 'streams.i'
210 ]
211
212swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
213 USE_SWIG, swig_force, swig_args)
214
215copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
216copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
217
218
219if IN_CVS_TREE: # update the licence files
220 mkpath('licence')
221 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
222 copy_file(WXDIR+'/docs/'+file, 'licence/'+file, update=1, verbose=0)
223
224
225if os.name == 'nt':
226 rc_file = ['src/wxc.rc']
227else:
228 rc_file = []
229
230
231wxext = ext = Extension('wxc', ['src/helpers.cpp',
232 'src/libpy.c',
233 ] + rc_file + swig_sources,
234
235 include_dirs = includes,
236 define_macros = defines,
237
238 library_dirs = libdirs,
239 libraries = libs,
240
241 extra_compile_args = cflags,
242 extra_link_args = lflags,
243 )
244
245
246wxpExtensions.append(ext)
247
248if os.name == 'nt':
249 libs = libs[:]
250 if debug:
251 libs.insert(0, 'wxc_d')
252 else:
253 libs.insert(0, 'wxc')
254
255#----------------------------------------------------------------------
256# Define the GLCanvas extension module
257#----------------------------------------------------------------------
258
259if not BUILD_GLCANVAS:
260 wxext.sources = wxext.sources + ['contrib/glcanvas/stub.cpp']
261else:
262 print 'Preparing GLCANVAS...'
263 location = 'contrib/glcanvas'
264 swig_files = ['glcanvas.i']
265
266 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
267 USE_SWIG, swig_force, swig_args)
268
269 gl_libs = []
270 if os.name == 'posix':
271 if '-D__WXDEBUG__' in cflags:
272 gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
273 else:
274 gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
275
276 wxext.sources = wxext.sources + swig_sources
277 wxext.libraries = wxext.libraries + gl_libs
278
279
280#----------------------------------------------------------------------
281# Define the OGL extension module
282#----------------------------------------------------------------------
283
284
285if not BUILD_OGL:
286 wxext.sources = wxext.sources + ['contrib/ogl/stub.cpp']
287else:
288 print 'Preparing OGL...'
289 location = 'contrib/ogl'
290 OGLLOC = location + '/contrib/src/ogl'
291 OGLINC = location + '/contrib/include'
292
293 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
294 'oglcanvas.i']
295
296 swig_sources = run_swig(swig_files, location, '', PKGDIR,
297 USE_SWIG, swig_force, swig_args)
298
299 # make sure local copy of contrib files are up to date
300 if IN_CVS_TREE:
301 contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
302 contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
303
304 # add items to the core extension module definition
305 wxext.sources = wxext.sources + [location + '/oglhelpers.cpp',
306 '%s/basic.cpp' % OGLLOC,
307 '%s/bmpshape.cpp' % OGLLOC,
308 '%s/composit.cpp' % OGLLOC,
309 '%s/divided.cpp' % OGLLOC,
310 '%s/lines.cpp' % OGLLOC,
311 '%s/misc.cpp' % OGLLOC,
312 '%s/basic2.cpp' % OGLLOC,
313 '%s/canvas.cpp' % OGLLOC,
314 '%s/constrnt.cpp' % OGLLOC,
315 '%s/drawn.cpp' % OGLLOC,
316 '%s/mfutils.cpp' % OGLLOC,
317 '%s/ogldiag.cpp' % OGLLOC,
318 ] + swig_sources
319
320 wxext.include_dirs = wxext.include_dirs + [OGLINC]
321
322#----------------------------------------------------------------------
323# Define the STC extension module
324#----------------------------------------------------------------------
325
326
327if not BUILD_STC:
328 wxext.sources = wxext.sources + ['contrib/stc/stub.cpp']
329else:
330 print 'Preparing STC...'
331 location = 'contrib/stc'
332 STCLOC = location + '/contrib/src/stc'
333 STCINC = location + '/contrib/include'
334 STC_H = location + '/contrib/include/wx/stc'
335
336 # make sure local copy of contrib files are up to date
337 if IN_CVS_TREE:
338 contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
339 contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
340
341
342 swig_files = ['stc_.i']
343 swig_sources = run_swig(swig_files, location, '', PKGDIR,
344 USE_SWIG, swig_force,
345 swig_args + ['-I'+STC_H, '-I'+location],
346 [STC_H+'/stc.h'])
347
348 # copy a project specific py module to the main package dir
349 copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
350
351 # add some include dirs to the standard set
352 stc_includes = [ '%s/scintilla/include' % STCLOC,
353 '%s/scintilla/src' % STCLOC,
354 STCINC ]
355
356 # and some macro definitions
357 stc_defines = [ ('__WX__', None),
358 ('SCI_LEXER', None) ]
359
360
361 # add items to the core extension module definition
362 wxext.sources = wxext.sources + [
363 '%s/scintilla/src/AutoComplete.cxx' % STCLOC,
364 '%s/scintilla/src/CallTip.cxx' % STCLOC,
365 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
366 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
367 '%s/scintilla/src/Document.cxx' % STCLOC,
368 '%s/scintilla/src/Editor.cxx' % STCLOC,
369 '%s/scintilla/src/Indicator.cxx' % STCLOC,
370 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
371 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
372 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
373 '%s/scintilla/src/PropSet.cxx' % STCLOC,
374 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
375 '%s/scintilla/src/Style.cxx' % STCLOC,
376 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
377 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
378 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
379 '%s/scintilla/src/LexLua.cxx' % STCLOC,
380 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
381 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
382 '%s/scintilla/src/LexPython.cxx' % STCLOC,
383 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
384 '%s/scintilla/src/LexVB.cxx' % STCLOC,
385 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
386 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
387 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
388 '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
389
390 '%s/PlatWX.cpp' % STCLOC,
391 '%s/ScintillaWX.cpp' % STCLOC,
392 '%s/stc.cpp' % STCLOC,
393 ] + swig_sources
394
395 wxext.include_dirs = wxext.include_dirs + stc_includes
396 wxext.define_macros = wxext.define_macros + stc_defines
397
398
399
400#----------------------------------------------------------------------
401# Do the Setup/Build/Install/Whatever
402#----------------------------------------------------------------------
403
404setup(name = PKGDIR,
405 version = VERSION,
406 description = DESCRIPTION,
407 long_description = LONG_DESCRIPTION,
408 author = AUTHOR,
409 author_email = AUTHOR_EMAIL,
410 url = URL,
411 licence = LICENCE,
412
413 packages = [PKGDIR,
414 PKGDIR+'.lib',
415 PKGDIR+'.lib.editor',
416 ],
417
418 ext_package = PKGDIR,
419 ext_modules = wxpExtensions,
420
421 )
422
423
424
425
426#----------------------------------------------------------------------
427#----------------------------------------------------------------------
428#----------------------------------------------------------------------
429
430# The pre-distutils binary distributions of wxPython included the demo
431# as a subdirectory of the package dir. This doesn't really make sense
432# for Linux/Unix platforms as it's not part of the package, and the user
433# may want to tweak and learn without having to become root first.
434#
435# For now I am going to start distributing the demo as a separate tarball,
436# but if I ever want to go back to the old way, this is how to do it the
437# distutils way:
438
439
440## from my_install_data import *
441
442## Add this to the setup() call
443## # Overridden command classes
444## cmdclass = {'install_data': my_install_data},
445## # non python files of examples
446## data_files = [
447## Data_Files(
448## base_dir='install_lib',
449## copy_to = 'wxPython',
450## #strip_dirs = 2,
451## template=[ 'graft demo',
452## 'global-exclude CVS/*'
453## ],
454## preserve_path=1
455## )
456## ],
457
458
459
460#----------------------------------------------------------------------
461#----------------------------------------------------------------------
462#----------------------------------------------------------------------
463
464# Originally I was building separate extension module .so's for the
465# CORE and the various contribs. Because of shared library issues I've
466# decided to combine things into one .so as implemented above, but as
467# I'm still not entirely convinced that this is the right thing to do
468# I will keep the old code around for a while, but commented out below.
469
470## if BUILD_GLCANVAS:
471## print 'Preparing GLCANVAS...'
472## location = 'contrib/glcanvas'
473## swig_files = ['glcanvas.i']
474
475## swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
476## USE_SWIG, swig_force, swig_args)
477
478## gl_libs = []
479## if os.name == 'posix':
480## if '-D__WXDEBUG__' in cflags:
481## gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
482## else:
483## gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
484
485## ext = Extension('glcanvasc',
486## swig_sources,
487
488## include_dirs = includes,
489## define_macros = defines,
490
491## library_dirs = libdirs,
492## libraries = libs + gl_libs,
493
494## extra_compile_args = cflags,
495## extra_link_args = lflags,
496## )
497
498## wxpExtensions.append(ext)
499
500
501
502## if BUILD_OGL:
503## print 'Preparing OGL...'
504## location = 'contrib/ogl'
505## OGLLOC = location + '/contrib/src/ogl'
506## OGLINC = location + '/contrib/include'
507
508## swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
509## 'oglcanvas.i']
510
511## swig_sources = run_swig(swig_files, location, '', PKGDIR,
512## USE_SWIG, swig_force, swig_args)
513
514## # make sure local copy of contrib files are up to date
515## if IN_CVS_TREE:
516## contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
517## contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
518
519## ext = Extension('oglc', [location + '/oglhelpers.cpp',
520## '%s/basic.cpp' % OGLLOC,
521## '%s/bmpshape.cpp' % OGLLOC,
522## '%s/composit.cpp' % OGLLOC,
523## '%s/divided.cpp' % OGLLOC,
524## '%s/lines.cpp' % OGLLOC,
525## '%s/misc.cpp' % OGLLOC,
526## '%s/basic2.cpp' % OGLLOC,
527## '%s/canvas.cpp' % OGLLOC,
528## '%s/constrnt.cpp' % OGLLOC,
529## '%s/drawn.cpp' % OGLLOC,
530## '%s/mfutils.cpp' % OGLLOC,
531## '%s/ogldiag.cpp' % OGLLOC,
532## ] + swig_sources,
533
534## include_dirs = [OGLINC] + includes,
535## define_macros = defines,
536
537## library_dirs = libdirs,
538## libraries = libs,
539
540## extra_compile_args = cflags,
541## extra_link_args = lflags,
542## )
543
544## wxpExtensions.append(ext)
545
546
547
548## if BUILD_STC:
549## print 'Preparing STC...'
550## location = 'contrib/stc'
551## STCLOC = location + '/contrib/src/stc'
552## STCINC = location + '/contrib/include'
553## STC_H = location + '/contrib/include/wx/stc'
554
555## # make sure local copy of contrib files are up to date
556## if IN_CVS_TREE:
557## contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
558## contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
559
560
561## swig_files = ['stc_.i']
562## swig_sources = run_swig(swig_files, location, '', PKGDIR,
563## USE_SWIG, swig_force,
564## swig_args + ['-I'+STC_H, '-I'+location],
565## [STC_H+'/stc.h'])
566
567## # copy a project specific py module to the main package dir
568## copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
569
570## # add some include dirs to the standard set
571## stc_includes = includes[:]
572## stc_includes.append('%s/scintilla/include' % STCLOC)
573## stc_includes.append('%s/scintilla/src' % STCLOC)
574## stc_includes.append(STCINC)
575
576## # and some macro definitions
577## stc_defines = defines[:]
578## stc_defines.append( ('__WX__', None) )
579## stc_defines.append( ('SCI_LEXER', None) )
580
581
582## ext = Extension('stc_c',
583## ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
584## '%s/scintilla/src/CallTip.cxx' % STCLOC,
585## '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
586## '%s/scintilla/src/ContractionState.cxx' % STCLOC,
587## '%s/scintilla/src/Document.cxx' % STCLOC,
588## '%s/scintilla/src/Editor.cxx' % STCLOC,
589## '%s/scintilla/src/Indicator.cxx' % STCLOC,
590## '%s/scintilla/src/KeyMap.cxx' % STCLOC,
591## '%s/scintilla/src/KeyWords.cxx' % STCLOC,
592## '%s/scintilla/src/LineMarker.cxx' % STCLOC,
593## '%s/scintilla/src/PropSet.cxx' % STCLOC,
594## '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
595## '%s/scintilla/src/Style.cxx' % STCLOC,
596## '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
597## '%s/scintilla/src/LexCPP.cxx' % STCLOC,
598## '%s/scintilla/src/LexHTML.cxx' % STCLOC,
599## '%s/scintilla/src/LexLua.cxx' % STCLOC,
600## '%s/scintilla/src/LexOthers.cxx' % STCLOC,
601## '%s/scintilla/src/LexPerl.cxx' % STCLOC,
602## '%s/scintilla/src/LexPython.cxx' % STCLOC,
603## '%s/scintilla/src/LexSQL.cxx' % STCLOC,
604## '%s/scintilla/src/LexVB.cxx' % STCLOC,
605## '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
606## '%s/scintilla/src/UniConversion.cxx' % STCLOC,
607## '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
608## '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
609
610## '%s/PlatWX.cpp' % STCLOC,
611## '%s/ScintillaWX.cpp' % STCLOC,
612## '%s/stc.cpp' % STCLOC,
613## ] + swig_sources,
614
615## include_dirs = stc_includes,
616## define_macros = stc_defines,
617
618## library_dirs = libdirs,
619## libraries = libs,
620
621## extra_compile_args = cflags,
622## extra_link_args = lflags,
623## )
624
625## wxpExtensions.append(ext)
626
627