]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/setup.py
2 #----------------------------------------------------------------------
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
10 from my_distutils
import run_swig
, contrib_copy_tree
12 #----------------------------------------------------------------------
13 # flags and values that affect this script
14 #----------------------------------------------------------------------
17 DESCRIPTION
= "Cross platform GUI toolkit for Python"
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
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
38 USE_SWIG
= 0 # Should we actually execute SWIG, or just use the
39 # files already in the distribution?
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
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.
50 # Some MSW build settings
52 FINAL
= 1 # Mirrors use of same flag in wx makefiles,
53 # (0 or 1 only) should probably find a way to
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.)
63 WXDLLVER
= '23_0' # Version part of DLL name
66 #----------------------------------------------------------------------
68 #----------------------------------------------------------------------
73 force
= '--force' in sys
.argv
or '-f' in sys
.argv
74 debug
= '--debug' in sys
.argv
or '-g' in sys
.argv
77 #----------------------------------------------------------------------
78 # Check for build flags on the command line
79 #----------------------------------------------------------------------
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
87 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
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
95 vars()[option
] = sys
.argv
[x
][pos
:]
98 sys
.argv
= filter(None, sys
.argv
)
106 #----------------------------------------------------------------------
107 # Setup some platform specific stuff
108 #----------------------------------------------------------------------
111 # Set compile flags and such for MSVC. These values are derived
112 # from the wxWindows makefiles for MSVC, others will probably
114 WXDIR
= os
.environ
['WXWIN']
126 os
.path
.join(WXDIR
, 'include'),
129 defines
= [ ('WIN32', None), # Some of these are no longer
130 ('__WIN32__', None), # necessary. Anybody know which?
132 ('__WINDOWS__', None),
133 ('WINVER', '0x0400'),
140 ('SWIG_GLOBAL', None),
141 ('HAVE_CONFIG_H', None),
142 ('WXP_USE_THREAD', '1'),
145 if not FINAL
or HYBRID
:
146 defines
.append( ('__WXDEBUG__', None) )
148 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
151 wxdll
= 'wx' + WXDLLVER
153 wxdll
= 'wx' + WXDLLVER
+ 'h'
155 wxdll
= 'wx' + WXDLLVER
+ 'd'
158 libs
= [wxdll
, 'kernel32', 'user32', 'gdi32', 'comdlg32',
159 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
160 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
161 'advapi32', 'wsock32']
163 cflags
= ['/GX-'] # workaround for internal compiler error in MSVC 5
166 if not FINAL
and HYBRID
:
167 cflags
= cflags
+ ['/Od', '/Z7']
168 lflags
= ['/DEBUG', ]
171 elif os
.name
== 'posix':
172 # Set flags for Unix type platforms
174 WXDIR
= '..' # assumes IN_CVS_TREE
175 WXPLAT
= '__WXGTK__' # and assumes GTK...
176 GENDIR
= 'gtk' # Need to allow for Motif eventually too
179 defines
= [('SWIG_GLOBAL', None),
180 ('HAVE_CONFIG_H', None),
181 ('WXP_USE_THREAD', '1'),
186 cflags
= os
.popen(WX_CONFIG
+ ' --cflags', 'r').read()[:-1] + ' ' + \
187 os
.popen('gtk-config --cflags', 'r').read()[:-1]
188 cflags
= string
.split(cflags
)
190 lflags
= os
.popen(WX_CONFIG
+ ' --libs', 'r').read()[:-1]
191 lflags
= string
.split(lflags
)
195 raise 'Sorry Charlie...'
198 #----------------------------------------------------------------------
199 # Check if the version file needs updated
200 #----------------------------------------------------------------------
202 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
203 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
207 #----------------------------------------------------------------------
209 #----------------------------------------------------------------------
212 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
213 '-I./src', '-D'+WXPLAT
]
214 swig_deps
= ['src/my_typemaps.i']
217 #----------------------------------------------------------------------
218 # Define the CORE extension module
219 #----------------------------------------------------------------------
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',
231 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
232 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
234 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
235 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
238 if IN_CVS_TREE
: # update the licence files
240 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
241 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
245 rc_file
= ['src/wxc.rc']
250 ext
= Extension('wxc', ['src/helpers.cpp',
252 ] + rc_file
+ swig_sources
,
254 include_dirs
= includes
,
255 define_macros
= defines
,
257 library_dirs
= libdirs
,
260 extra_compile_args
= cflags
,
261 extra_link_args
= lflags
,
263 wxpExtensions
.append(ext
)
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
,
274 extra_compile_args
= cflags
,
275 extra_link_args
= lflags
,
277 wxpExtensions
.append(ext
)
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
,
288 extra_compile_args
= cflags
,
289 extra_link_args
= lflags
,
291 wxpExtensions
.append(ext
)
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
,
302 extra_compile_args
= cflags
,
303 extra_link_args
= lflags
,
305 wxpExtensions
.append(ext
)
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
,
316 extra_compile_args
= cflags
,
317 extra_link_args
= lflags
,
319 wxpExtensions
.append(ext
)
322 #----------------------------------------------------------------------
323 # Define the GLCanvas extension module
324 #----------------------------------------------------------------------
326 if BUILD_GLCANVAS
or GL_ONLY
:
327 print 'Preparing GLCANVAS...'
328 location
= 'contrib/glcanvas'
329 swig_files
= ['glcanvas.i']
332 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
333 USE_SWIG
, swig_force
, swig_args
)
336 if os
.name
== 'posix':
337 if '-D__WXDEBUG__' in cflags
:
338 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
340 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
342 other_sources
= [location
+ '/msw/myglcanvas.cpp']
343 gl_libs
= ['opengl32', 'glu32']
346 ext
= Extension('glcanvasc',
347 swig_sources
+ other_sources
,
349 include_dirs
= includes
,
350 define_macros
= defines
,
352 library_dirs
= libdirs
,
353 libraries
= libs
+ gl_libs
,
355 extra_compile_args
= cflags
,
356 extra_link_args
= lflags
,
359 wxpExtensions
.append(ext
)
362 #----------------------------------------------------------------------
363 # Define the OGL extension module
364 #----------------------------------------------------------------------
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'
372 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
375 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
376 USE_SWIG
, swig_force
, swig_args
)
378 # make sure local copy of contrib files are up to date
380 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
381 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
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
,
397 include_dirs
= [OGLINC
] + includes
,
398 define_macros
= defines
,
400 library_dirs
= libdirs
,
403 extra_compile_args
= cflags
,
404 extra_link_args
= lflags
,
407 wxpExtensions
.append(ext
)
411 #----------------------------------------------------------------------
412 # Define the STC extension module
413 #----------------------------------------------------------------------
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'
422 # make sure local copy of contrib files are up to date
424 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
425 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
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
],
434 # copy a project specific py module to the main package dir
435 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
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
)
443 # and some macro definitions
444 stc_defines
= defines
[:]
445 stc_defines
.append( ('__WX__', None) )
446 stc_defines
.append( ('SCI_LEXER', None) )
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
,
477 '%s/PlatWX.cpp' % STCLOC
,
478 '%s/ScintillaWX.cpp' % STCLOC
,
479 '%s/stc.cpp' % STCLOC
,
482 include_dirs
= stc_includes
,
483 define_macros
= stc_defines
,
485 library_dirs
= libdirs
,
488 extra_compile_args
= cflags
,
489 extra_link_args
= lflags
,
492 wxpExtensions
.append(ext
)
496 #----------------------------------------------------------------------
497 # Do the Setup/Build/Install/Whatever
498 #----------------------------------------------------------------------
500 if __name__
== "__main__":
504 description
= DESCRIPTION
,
505 long_description
= LONG_DESCRIPTION
,
507 author_email
= AUTHOR_EMAIL
,
513 PKGDIR
+'.lib.editor',
516 ext_package
= PKGDIR
,
517 ext_modules
= wxpExtensions
,
522 setup(name
= "wxPython-gl",
524 description
= "wxGLCanvas class for wxPython",
526 author_email
= AUTHOR_EMAIL
,
530 py_modules
= [ "wxPython.glcanvas" ],
532 ext_package
= PKGDIR
,
533 ext_modules
= wxpExtensions
,
539 #----------------------------------------------------------------------
540 #----------------------------------------------------------------------