]> git.saurik.com Git - wxWidgets.git/blame - wxPython/setup.py
2nd part of wxRegConfig fix
[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
de20db99 16VERSION = "2.3b1"
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
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
de20db99 202swig_args = ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
c368d904 203 '-I./src', '-D'+WXPLAT]
185d7c3e 204swig_deps = ['src/my_typemaps.i']
c368d904
RD
205
206swig_files = [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
207 'misc.i', 'misc2.i', 'utils.i', 'gdi.i', 'mdi.i', 'controls.i',
208 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
209 'printfw.i', 'sizers.i', 'clip_dnd.i', 'grid.i', 'html.i',
210 'htmlhelp.i', 'calendar.i', 'filesys.i', 'streams.i'
211 ]
212
213swig_sources = run_swig(swig_files, 'src', GENDIR, PKGDIR,
185d7c3e 214 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904
RD
215
216copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
217copy_file('src/__version__.py', PKGDIR, update=1, verbose=0)
218
219
220if IN_CVS_TREE: # update the licence files
221 mkpath('licence')
222 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
223 copy_file(WXDIR+'/docs/'+file, 'licence/'+file, update=1, verbose=0)
224
225
226if os.name == 'nt':
227 rc_file = ['src/wxc.rc']
228else:
229 rc_file = []
230
231
232wxext = ext = Extension('wxc', ['src/helpers.cpp',
233 'src/libpy.c',
234 ] + rc_file + swig_sources,
235
236 include_dirs = includes,
237 define_macros = defines,
238
239 library_dirs = libdirs,
240 libraries = libs,
241
242 extra_compile_args = cflags,
243 extra_link_args = lflags,
244 )
245
246
247wxpExtensions.append(ext)
248
249if os.name == 'nt':
250 libs = libs[:]
251 if debug:
252 libs.insert(0, 'wxc_d')
253 else:
254 libs.insert(0, 'wxc')
255
256#----------------------------------------------------------------------
257# Define the GLCanvas extension module
258#----------------------------------------------------------------------
259
260if not BUILD_GLCANVAS:
261 wxext.sources = wxext.sources + ['contrib/glcanvas/stub.cpp']
262else:
263 print 'Preparing GLCANVAS...'
264 location = 'contrib/glcanvas'
265 swig_files = ['glcanvas.i']
266
267 swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
185d7c3e 268 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904
RD
269
270 gl_libs = []
271 if os.name == 'posix':
272 if '-D__WXDEBUG__' in cflags:
273 gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
274 else:
275 gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
276
277 wxext.sources = wxext.sources + swig_sources
278 wxext.libraries = wxext.libraries + gl_libs
279
280
281#----------------------------------------------------------------------
282# Define the OGL extension module
283#----------------------------------------------------------------------
284
285
286if not BUILD_OGL:
287 wxext.sources = wxext.sources + ['contrib/ogl/stub.cpp']
288else:
289 print 'Preparing OGL...'
290 location = 'contrib/ogl'
291 OGLLOC = location + '/contrib/src/ogl'
292 OGLINC = location + '/contrib/include'
293
294 swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
295 'oglcanvas.i']
296
297 swig_sources = run_swig(swig_files, location, '', PKGDIR,
185d7c3e 298 USE_SWIG, swig_force, swig_args, swig_deps)
c368d904
RD
299
300 # make sure local copy of contrib files are up to date
301 if IN_CVS_TREE:
302 contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
303 contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
304
305 # add items to the core extension module definition
306 wxext.sources = wxext.sources + [location + '/oglhelpers.cpp',
307 '%s/basic.cpp' % OGLLOC,
308 '%s/bmpshape.cpp' % OGLLOC,
309 '%s/composit.cpp' % OGLLOC,
310 '%s/divided.cpp' % OGLLOC,
311 '%s/lines.cpp' % OGLLOC,
312 '%s/misc.cpp' % OGLLOC,
313 '%s/basic2.cpp' % OGLLOC,
314 '%s/canvas.cpp' % OGLLOC,
315 '%s/constrnt.cpp' % OGLLOC,
316 '%s/drawn.cpp' % OGLLOC,
317 '%s/mfutils.cpp' % OGLLOC,
318 '%s/ogldiag.cpp' % OGLLOC,
319 ] + swig_sources
320
321 wxext.include_dirs = wxext.include_dirs + [OGLINC]
322
323#----------------------------------------------------------------------
324# Define the STC extension module
325#----------------------------------------------------------------------
326
327
328if not BUILD_STC:
329 wxext.sources = wxext.sources + ['contrib/stc/stub.cpp']
330else:
331 print 'Preparing STC...'
332 location = 'contrib/stc'
333 STCLOC = location + '/contrib/src/stc'
334 STCINC = location + '/contrib/include'
335 STC_H = location + '/contrib/include/wx/stc'
336
337 # make sure local copy of contrib files are up to date
338 if IN_CVS_TREE:
339 contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
340 contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
341
342
343 swig_files = ['stc_.i']
344 swig_sources = run_swig(swig_files, location, '', PKGDIR,
345 USE_SWIG, swig_force,
346 swig_args + ['-I'+STC_H, '-I'+location],
185d7c3e 347 swig_deps + [STC_H+'/stc.h'])
c368d904
RD
348
349 # copy a project specific py module to the main package dir
350 copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
351
352 # add some include dirs to the standard set
353 stc_includes = [ '%s/scintilla/include' % STCLOC,
354 '%s/scintilla/src' % STCLOC,
355 STCINC ]
356
357 # and some macro definitions
358 stc_defines = [ ('__WX__', None),
359 ('SCI_LEXER', None) ]
360
361
362 # add items to the core extension module definition
363 wxext.sources = wxext.sources + [
364 '%s/scintilla/src/AutoComplete.cxx' % STCLOC,
365 '%s/scintilla/src/CallTip.cxx' % STCLOC,
366 '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
367 '%s/scintilla/src/ContractionState.cxx' % STCLOC,
368 '%s/scintilla/src/Document.cxx' % STCLOC,
369 '%s/scintilla/src/Editor.cxx' % STCLOC,
370 '%s/scintilla/src/Indicator.cxx' % STCLOC,
371 '%s/scintilla/src/KeyMap.cxx' % STCLOC,
372 '%s/scintilla/src/KeyWords.cxx' % STCLOC,
373 '%s/scintilla/src/LineMarker.cxx' % STCLOC,
374 '%s/scintilla/src/PropSet.cxx' % STCLOC,
375 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
376 '%s/scintilla/src/Style.cxx' % STCLOC,
377 '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
378 '%s/scintilla/src/LexCPP.cxx' % STCLOC,
379 '%s/scintilla/src/LexHTML.cxx' % STCLOC,
380 '%s/scintilla/src/LexLua.cxx' % STCLOC,
381 '%s/scintilla/src/LexOthers.cxx' % STCLOC,
382 '%s/scintilla/src/LexPerl.cxx' % STCLOC,
383 '%s/scintilla/src/LexPython.cxx' % STCLOC,
384 '%s/scintilla/src/LexSQL.cxx' % STCLOC,
385 '%s/scintilla/src/LexVB.cxx' % STCLOC,
386 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
387 '%s/scintilla/src/UniConversion.cxx' % STCLOC,
388 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
389 '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
390
391 '%s/PlatWX.cpp' % STCLOC,
392 '%s/ScintillaWX.cpp' % STCLOC,
393 '%s/stc.cpp' % STCLOC,
394 ] + swig_sources
395
396 wxext.include_dirs = wxext.include_dirs + stc_includes
397 wxext.define_macros = wxext.define_macros + stc_defines
398
399
400
401#----------------------------------------------------------------------
402# Do the Setup/Build/Install/Whatever
403#----------------------------------------------------------------------
404
405setup(name = PKGDIR,
406 version = VERSION,
407 description = DESCRIPTION,
408 long_description = LONG_DESCRIPTION,
409 author = AUTHOR,
410 author_email = AUTHOR_EMAIL,
411 url = URL,
412 licence = LICENCE,
413
414 packages = [PKGDIR,
415 PKGDIR+'.lib',
416 PKGDIR+'.lib.editor',
417 ],
418
419 ext_package = PKGDIR,
420 ext_modules = wxpExtensions,
421
422 )
423
424
425
426
427#----------------------------------------------------------------------
428#----------------------------------------------------------------------
429#----------------------------------------------------------------------
430
431# The pre-distutils binary distributions of wxPython included the demo
432# as a subdirectory of the package dir. This doesn't really make sense
433# for Linux/Unix platforms as it's not part of the package, and the user
434# may want to tweak and learn without having to become root first.
435#
436# For now I am going to start distributing the demo as a separate tarball,
437# but if I ever want to go back to the old way, this is how to do it the
438# distutils way:
439
440
441## from my_install_data import *
442
443## Add this to the setup() call
444## # Overridden command classes
445## cmdclass = {'install_data': my_install_data},
446## # non python files of examples
447## data_files = [
448## Data_Files(
449## base_dir='install_lib',
450## copy_to = 'wxPython',
451## #strip_dirs = 2,
452## template=[ 'graft demo',
453## 'global-exclude CVS/*'
454## ],
455## preserve_path=1
456## )
457## ],
458
459
460
461#----------------------------------------------------------------------
462#----------------------------------------------------------------------
463#----------------------------------------------------------------------
464
465# Originally I was building separate extension module .so's for the
466# CORE and the various contribs. Because of shared library issues I've
467# decided to combine things into one .so as implemented above, but as
468# I'm still not entirely convinced that this is the right thing to do
469# I will keep the old code around for a while, but commented out below.
470
471## if BUILD_GLCANVAS:
472## print 'Preparing GLCANVAS...'
473## location = 'contrib/glcanvas'
474## swig_files = ['glcanvas.i']
475
476## swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
477## USE_SWIG, swig_force, swig_args)
478
479## gl_libs = []
480## if os.name == 'posix':
481## if '-D__WXDEBUG__' in cflags:
482## gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
483## else:
484## gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
485
486## ext = Extension('glcanvasc',
487## swig_sources,
488
489## include_dirs = includes,
490## define_macros = defines,
491
492## library_dirs = libdirs,
493## libraries = libs + gl_libs,
494
495## extra_compile_args = cflags,
496## extra_link_args = lflags,
497## )
498
499## wxpExtensions.append(ext)
500
501
502
503## if BUILD_OGL:
504## print 'Preparing OGL...'
505## location = 'contrib/ogl'
506## OGLLOC = location + '/contrib/src/ogl'
507## OGLINC = location + '/contrib/include'
508
509## swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
510## 'oglcanvas.i']
511
512## swig_sources = run_swig(swig_files, location, '', PKGDIR,
513## USE_SWIG, swig_force, swig_args)
514
515## # make sure local copy of contrib files are up to date
516## if IN_CVS_TREE:
517## contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
518## contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
519
520## ext = Extension('oglc', [location + '/oglhelpers.cpp',
521## '%s/basic.cpp' % OGLLOC,
522## '%s/bmpshape.cpp' % OGLLOC,
523## '%s/composit.cpp' % OGLLOC,
524## '%s/divided.cpp' % OGLLOC,
525## '%s/lines.cpp' % OGLLOC,
526## '%s/misc.cpp' % OGLLOC,
527## '%s/basic2.cpp' % OGLLOC,
528## '%s/canvas.cpp' % OGLLOC,
529## '%s/constrnt.cpp' % OGLLOC,
530## '%s/drawn.cpp' % OGLLOC,
531## '%s/mfutils.cpp' % OGLLOC,
532## '%s/ogldiag.cpp' % OGLLOC,
533## ] + swig_sources,
534
535## include_dirs = [OGLINC] + includes,
536## define_macros = defines,
537
538## library_dirs = libdirs,
539## libraries = libs,
540
541## extra_compile_args = cflags,
542## extra_link_args = lflags,
543## )
544
545## wxpExtensions.append(ext)
546
547
548
549## if BUILD_STC:
550## print 'Preparing STC...'
551## location = 'contrib/stc'
552## STCLOC = location + '/contrib/src/stc'
553## STCINC = location + '/contrib/include'
554## STC_H = location + '/contrib/include/wx/stc'
555
556## # make sure local copy of contrib files are up to date
557## if IN_CVS_TREE:
558## contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
559## contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
560
561
562## swig_files = ['stc_.i']
563## swig_sources = run_swig(swig_files, location, '', PKGDIR,
564## USE_SWIG, swig_force,
565## swig_args + ['-I'+STC_H, '-I'+location],
566## [STC_H+'/stc.h'])
567
568## # copy a project specific py module to the main package dir
569## copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
570
571## # add some include dirs to the standard set
572## stc_includes = includes[:]
573## stc_includes.append('%s/scintilla/include' % STCLOC)
574## stc_includes.append('%s/scintilla/src' % STCLOC)
575## stc_includes.append(STCINC)
576
577## # and some macro definitions
578## stc_defines = defines[:]
579## stc_defines.append( ('__WX__', None) )
580## stc_defines.append( ('SCI_LEXER', None) )
581
582
583## ext = Extension('stc_c',
584## ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
585## '%s/scintilla/src/CallTip.cxx' % STCLOC,
586## '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
587## '%s/scintilla/src/ContractionState.cxx' % STCLOC,
588## '%s/scintilla/src/Document.cxx' % STCLOC,
589## '%s/scintilla/src/Editor.cxx' % STCLOC,
590## '%s/scintilla/src/Indicator.cxx' % STCLOC,
591## '%s/scintilla/src/KeyMap.cxx' % STCLOC,
592## '%s/scintilla/src/KeyWords.cxx' % STCLOC,
593## '%s/scintilla/src/LineMarker.cxx' % STCLOC,
594## '%s/scintilla/src/PropSet.cxx' % STCLOC,
595## '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
596## '%s/scintilla/src/Style.cxx' % STCLOC,
597## '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
598## '%s/scintilla/src/LexCPP.cxx' % STCLOC,
599## '%s/scintilla/src/LexHTML.cxx' % STCLOC,
600## '%s/scintilla/src/LexLua.cxx' % STCLOC,
601## '%s/scintilla/src/LexOthers.cxx' % STCLOC,
602## '%s/scintilla/src/LexPerl.cxx' % STCLOC,
603## '%s/scintilla/src/LexPython.cxx' % STCLOC,
604## '%s/scintilla/src/LexSQL.cxx' % STCLOC,
605## '%s/scintilla/src/LexVB.cxx' % STCLOC,
606## '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
607## '%s/scintilla/src/UniConversion.cxx' % STCLOC,
608## '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
609## '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
610
611## '%s/PlatWX.cpp' % STCLOC,
612## '%s/ScintillaWX.cpp' % STCLOC,
613## '%s/stc.cpp' % STCLOC,
614## ] + swig_sources,
615
616## include_dirs = stc_includes,
617## define_macros = stc_defines,
618
619## library_dirs = libdirs,
620## libraries = libs,
621
622## extra_compile_args = cflags,
623## extra_link_args = lflags,
624## )
625
626## wxpExtensions.append(ext)
627
628