]>
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
46 # Some MSW build settings
48 FINAL
= 1 # Mirrors use of same flag in wx makefiles,
49 # (0 or 1 only) should probably find a way to
52 HYBRID
= 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.)
59 WXDLLVER
= '23_0' # Version part of DLL name
62 #----------------------------------------------------------------------
64 #----------------------------------------------------------------------
69 force
= '--force' in sys
.argv
or '-f' in sys
.argv
70 debug
= '--debug' in sys
.argv
or '-g' in sys
.argv
73 #----------------------------------------------------------------------
74 # Check for build flags on the command line
75 #----------------------------------------------------------------------
77 for flag
in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
78 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID',
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
84 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
87 sys
.argv
= filter(None, sys
.argv
)
95 #----------------------------------------------------------------------
96 # Setup some platform specific stuff
97 #----------------------------------------------------------------------
100 # Set compile flags and such for MSVC. These values are derived
101 # from the wxWindows makefiles for MSVC, others will probably
103 WXDIR
= os
.environ
['WXWIN']
115 os
.path
.join(WXDIR
, 'include'),
118 defines
= [ ('WIN32', None), # Some of these are no longer
119 ('__WIN32__', None), # necessary. Anybody know which?
121 ('__WINDOWS__', None),
122 ('WINVER', '0x0400'),
129 ('SWIG_GLOBAL', None),
130 ('HAVE_CONFIG_H', None),
131 ('WXP_USE_THREAD', '1'),
134 if not FINAL
or HYBRID
:
135 defines
.append( ('__WXDEBUG__', None) )
137 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
140 wxdll
= 'wx' + WXDLLVER
142 wxdll
= 'wx' + WXDLLVER
+ 'h'
144 wxdll
= 'wx' + WXDLLVER
+ 'd'
147 libs
= [wxdll
, 'kernel32', 'user32', 'gdi32', 'comdlg32',
148 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
149 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
150 'advapi32', 'wsock32']
152 cflags
= ['/GX-'] # workaround for internal compiler error in MSVC 5
155 if not FINAL
and HYBRID
:
156 cflags
= cflags
+ ['/Od', '/Z7']
157 lflags
= ['/DEBUG', ]
160 elif os
.name
== 'posix':
161 # Set flags for Unix type platforms
163 WXDIR
= '..' # assumes IN_CVS_TREE
164 WXPLAT
= '__WXGTK__' # and assumes GTK...
165 GENDIR
= 'gtk' # Need to allow for Motif eventually too
168 defines
= [('SWIG_GLOBAL', None),
169 ('HAVE_CONFIG_H', None),
170 ('WXP_USE_THREAD', '1'),
175 cflags
= os
.popen('wx-config --cflags', 'r').read()[:-1] + ' ' + \
176 os
.popen('gtk-config --cflags', 'r').read()[:-1]
177 cflags
= string
.split(cflags
)
179 lflags
= os
.popen('wx-config --libs', 'r').read()[:-1]
180 lflags
= string
.split(lflags
)
184 raise 'Sorry Charlie...'
187 #----------------------------------------------------------------------
188 # Check if the version file needs updated
189 #----------------------------------------------------------------------
191 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
192 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
196 #----------------------------------------------------------------------
198 #----------------------------------------------------------------------
201 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
202 '-I./src', '-D'+WXPLAT
]
203 swig_deps
= ['src/my_typemaps.i']
206 #----------------------------------------------------------------------
207 # Define the CORE extension module
208 #----------------------------------------------------------------------
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',
220 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
221 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
223 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
224 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
227 if IN_CVS_TREE
: # update the licence files
229 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
230 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
234 rc_file
= ['src/wxc.rc']
239 ext
= Extension('wxc', ['src/helpers.cpp',
241 ] + rc_file
+ swig_sources
,
243 include_dirs
= includes
,
244 define_macros
= defines
,
246 library_dirs
= libdirs
,
249 extra_compile_args
= cflags
,
250 extra_link_args
= lflags
,
252 wxpExtensions
.append(ext
)
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
,
263 extra_compile_args
= cflags
,
264 extra_link_args
= lflags
,
266 wxpExtensions
.append(ext
)
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
,
277 extra_compile_args
= cflags
,
278 extra_link_args
= lflags
,
280 wxpExtensions
.append(ext
)
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
,
291 extra_compile_args
= cflags
,
292 extra_link_args
= lflags
,
294 wxpExtensions
.append(ext
)
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
,
305 extra_compile_args
= cflags
,
306 extra_link_args
= lflags
,
308 wxpExtensions
.append(ext
)
311 #----------------------------------------------------------------------
312 # Define the GLCanvas extension module
313 #----------------------------------------------------------------------
315 if BUILD_GLCANVAS
or GL_ONLY
:
316 print 'Preparing GLCANVAS...'
317 location
= 'contrib/glcanvas'
318 swig_files
= ['glcanvas.i']
320 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
321 USE_SWIG
, swig_force
, swig_args
)
324 if os
.name
== 'posix':
325 if '-D__WXDEBUG__' in cflags
:
326 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
328 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
330 ext
= Extension('glcanvasc',
333 include_dirs
= includes
,
334 define_macros
= defines
,
336 library_dirs
= libdirs
,
337 libraries
= libs
+ gl_libs
,
339 extra_compile_args
= cflags
,
340 extra_link_args
= lflags
,
343 wxpExtensions
.append(ext
)
346 #----------------------------------------------------------------------
347 # Define the OGL extension module
348 #----------------------------------------------------------------------
350 if not GL_ONLY
and BUILD_OGL
:
351 print 'Preparing OGL...'
352 location
= 'contrib/ogl'
353 OGLLOC
= location
+ '/contrib/src/ogl'
354 OGLINC
= location
+ '/contrib/include'
356 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
359 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
360 USE_SWIG
, swig_force
, swig_args
)
362 # make sure local copy of contrib files are up to date
364 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
365 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
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
,
381 include_dirs
= [OGLINC
] + includes
,
382 define_macros
= defines
,
384 library_dirs
= libdirs
,
387 extra_compile_args
= cflags
,
388 extra_link_args
= lflags
,
391 wxpExtensions
.append(ext
)
395 #----------------------------------------------------------------------
396 # Define the STC extension module
397 #----------------------------------------------------------------------
399 if not GL_ONLY
and BUILD_STC
:
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'
406 # make sure local copy of contrib files are up to date
408 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
409 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
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
],
418 # copy a project specific py module to the main package dir
419 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
421 # add some include dirs to the standard set
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
)
427 # and some macro definitions
428 stc_defines
= defines
[:]
429 stc_defines
.append( ('__WX__', None) )
430 stc_defines
.append( ('SCI_LEXER', None) )
433 ext
= Extension('stc_c',
434 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
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
,
461 '%s/PlatWX.cpp' % STCLOC
,
462 '%s/ScintillaWX.cpp' % STCLOC
,
463 '%s/stc.cpp' % STCLOC
,
466 include_dirs
= stc_includes
,
467 define_macros
= stc_defines
,
469 library_dirs
= libdirs
,
472 extra_compile_args
= cflags
,
473 extra_link_args
= lflags
,
476 wxpExtensions
.append(ext
)
480 #----------------------------------------------------------------------
481 # Do the Setup/Build/Install/Whatever
482 #----------------------------------------------------------------------
484 if __name__
== "__main__":
488 description
= DESCRIPTION
,
489 long_description
= LONG_DESCRIPTION
,
491 author_email
= AUTHOR_EMAIL
,
497 PKGDIR
+'.lib.editor',
500 ext_package
= PKGDIR
,
501 ext_modules
= wxpExtensions
,
506 setup(name
= "wxPython-gl",
508 description
= "wxGLCanvas class for wxPython",
510 author_email
= AUTHOR_EMAIL
,
514 py_modules
= [ "wxPython.glcanvas" ],
516 ext_package
= PKGDIR
,
517 ext_modules
= wxpExtensions
,
523 #----------------------------------------------------------------------
524 #----------------------------------------------------------------------