]>
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']
331 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
332 USE_SWIG
, swig_force
, swig_args
)
335 if os
.name
== 'posix':
336 if '-D__WXDEBUG__' in cflags
:
337 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
339 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
341 ext
= Extension('glcanvasc',
344 include_dirs
= includes
,
345 define_macros
= defines
,
347 library_dirs
= libdirs
,
348 libraries
= libs
+ gl_libs
,
350 extra_compile_args
= cflags
,
351 extra_link_args
= lflags
,
354 wxpExtensions
.append(ext
)
357 #----------------------------------------------------------------------
358 # Define the OGL extension module
359 #----------------------------------------------------------------------
361 if not GL_ONLY
and BUILD_OGL
:
362 print 'Preparing OGL...'
363 location
= 'contrib/ogl'
364 OGLLOC
= location
+ '/contrib/src/ogl'
365 OGLINC
= location
+ '/contrib/include'
367 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
370 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
371 USE_SWIG
, swig_force
, swig_args
)
373 # make sure local copy of contrib files are up to date
375 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
376 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
378 ext
= Extension('oglc', ['%s/basic.cpp' % OGLLOC
,
379 '%s/bmpshape.cpp' % OGLLOC
,
380 '%s/composit.cpp' % OGLLOC
,
381 '%s/divided.cpp' % OGLLOC
,
382 '%s/lines.cpp' % OGLLOC
,
383 '%s/misc.cpp' % OGLLOC
,
384 '%s/basic2.cpp' % OGLLOC
,
385 '%s/canvas.cpp' % OGLLOC
,
386 '%s/constrnt.cpp' % OGLLOC
,
387 '%s/drawn.cpp' % OGLLOC
,
388 '%s/mfutils.cpp' % OGLLOC
,
389 '%s/ogldiag.cpp' % OGLLOC
,
392 include_dirs
= [OGLINC
] + includes
,
393 define_macros
= defines
,
395 library_dirs
= libdirs
,
398 extra_compile_args
= cflags
,
399 extra_link_args
= lflags
,
402 wxpExtensions
.append(ext
)
406 #----------------------------------------------------------------------
407 # Define the STC extension module
408 #----------------------------------------------------------------------
410 if not GL_ONLY
and BUILD_STC
:
411 print 'Preparing STC...'
412 location
= 'contrib/stc'
413 STCLOC
= location
+ '/contrib/src/stc'
414 STCINC
= location
+ '/contrib/include'
415 STC_H
= location
+ '/contrib/include/wx/stc'
417 # make sure local copy of contrib files are up to date
419 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
420 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
423 swig_files
= ['stc_.i']
424 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
425 USE_SWIG
, swig_force
,
426 swig_args
+ ['-I'+STC_H
, '-I'+location
],
429 # copy a project specific py module to the main package dir
430 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
432 # add some include dirs to the standard set
433 stc_includes
= includes
[:]
434 stc_includes
.append('%s/scintilla/include' % STCLOC
)
435 stc_includes
.append('%s/scintilla/src' % STCLOC
)
436 stc_includes
.append(STCINC
)
438 # and some macro definitions
439 stc_defines
= defines
[:]
440 stc_defines
.append( ('__WX__', None) )
441 stc_defines
.append( ('SCI_LEXER', None) )
444 ext
= Extension('stc_c',
445 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
446 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
447 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
448 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
449 '%s/scintilla/src/Document.cxx' % STCLOC
,
450 '%s/scintilla/src/Editor.cxx' % STCLOC
,
451 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
452 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
453 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
454 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
455 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
456 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
457 '%s/scintilla/src/Style.cxx' % STCLOC
,
458 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
459 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
460 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
461 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
462 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
463 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
464 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
465 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
466 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
467 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
468 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
469 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
470 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
472 '%s/PlatWX.cpp' % STCLOC
,
473 '%s/ScintillaWX.cpp' % STCLOC
,
474 '%s/stc.cpp' % STCLOC
,
477 include_dirs
= stc_includes
,
478 define_macros
= stc_defines
,
480 library_dirs
= libdirs
,
483 extra_compile_args
= cflags
,
484 extra_link_args
= lflags
,
487 wxpExtensions
.append(ext
)
491 #----------------------------------------------------------------------
492 # Do the Setup/Build/Install/Whatever
493 #----------------------------------------------------------------------
495 if __name__
== "__main__":
499 description
= DESCRIPTION
,
500 long_description
= LONG_DESCRIPTION
,
502 author_email
= AUTHOR_EMAIL
,
508 PKGDIR
+'.lib.editor',
511 ext_package
= PKGDIR
,
512 ext_modules
= wxpExtensions
,
517 setup(name
= "wxPython-gl",
519 description
= "wxGLCanvas class for wxPython",
521 author_email
= AUTHOR_EMAIL
,
525 py_modules
= [ "wxPython.glcanvas" ],
527 ext_package
= PKGDIR
,
528 ext_modules
= wxpExtensions
,
534 #----------------------------------------------------------------------
535 #----------------------------------------------------------------------