]>
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 imlemented 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
36 USE_SWIG
= 0 # Should we actually execute SWIG, or just use the
37 # files already in the distribution?
39 IN_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
44 # Some MSW build settings
46 FINAL
= 1 # Mirrors use of same flag in wx makefiles,
47 # (0 or 1 only) should probably find a way to
50 HYBRID
= 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.)
57 WXDLLVER
= '23_0' # Version part of DLL name
60 #----------------------------------------------------------------------
62 #----------------------------------------------------------------------
67 force
= '--force' in sys
.argv
or '-f' in sys
.argv
68 debug
= '--debug' in sys
.argv
or '-g' in sys
.argv
71 #----------------------------------------------------------------------
72 # Check for build flags on the command line
73 #----------------------------------------------------------------------
75 for flag
in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
76 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID',
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
82 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
85 sys
.argv
= filter(None, sys
.argv
)
93 #----------------------------------------------------------------------
94 # Setup some platform specific stuff
95 #----------------------------------------------------------------------
98 # Set compile flags and such for MSVC. These values are derived
99 # from the wxWindows makefiles for MSVC, others will probably
101 WXDIR
= os
.environ
['WXWIN']
116 os
.path
.join(WXDIR
, 'include'),
119 defines
= [ ('WIN32', None), # Some of these are no longer
120 ('__WIN32__', None), # necessary. Anybody know which?
122 ('__WINDOWS__', None),
123 ('WINVER', '0x0400'),
130 ('SWIG_GLOBAL', None),
131 ('HAVE_CONFIG_H', None),
132 ('WXP_USE_THREAD', '1'),
135 if not FINAL
or HYBRID
:
136 defines
.append( ('__WXDEBUG__', None) )
138 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
141 wxdll
= 'wx' + WXDLLVER
143 wxdll
= 'wx' + WXDLLVER
+ 'h'
145 wxdll
= 'wx' + WXDLLVER
+ 'd'
147 #print 'Linking with ', wxdll
149 libs
= [wxdll
, 'kernel32', 'user32', 'gdi32', 'comdlg32',
150 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
151 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
152 'advapi32', 'wsock32']
154 cflags
= ['/GX-'] # workaround for internal compiler error in MSVC
157 if not FINAL
and HYBRID
:
158 cflags
= cflags
+ ['/Od', '/Z7']
159 lflags
= ['/DEBUG', ]
162 elif os
.name
== 'posix':
163 # Set flags for Unix type platforms
165 WXDIR
= '..' # assumes IN_CVS_TREE
166 WXPLAT
= '__WXGTK__' # and assumes GTK...
167 GENDIR
= 'gtk' # Need to allow for Motif eventually too
170 defines
= [('SWIG_GLOBAL', None),
171 ('HAVE_CONFIG_H', None),
172 ('WXP_USE_THREAD', '1'),
177 cflags
= os
.popen('wx-config --cflags', 'r').read()[:-1] + ' ' + \
178 os
.popen('gtk-config --cflags', 'r').read()[:-1]
179 cflags
= string
.split(cflags
)
181 lflags
= os
.popen('wx-config --libs', 'r').read()[:-1]
182 lflags
= string
.split(lflags
)
186 raise 'Sorry Charlie...'
189 #----------------------------------------------------------------------
190 # Check if the version file needs updated
191 #----------------------------------------------------------------------
193 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
194 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
196 #----------------------------------------------------------------------
197 # Define the CORE extension module
198 #----------------------------------------------------------------------
200 print 'Preparing CORE...'
202 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dascii',
203 '-I./src', '-D'+WXPLAT
]
204 swig_deps
= ['src/my_typemaps.i']
206 swig_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'
213 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
214 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
216 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
217 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
220 if IN_CVS_TREE
: # update the licence files
222 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
223 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
227 rc_file
= ['src/wxc.rc']
232 wxext
= ext
= Extension('wxc', ['src/helpers.cpp',
234 ] + rc_file
+ swig_sources
,
236 include_dirs
= includes
,
237 define_macros
= defines
,
239 library_dirs
= libdirs
,
242 extra_compile_args
= cflags
,
243 extra_link_args
= lflags
,
247 wxpExtensions
.append(ext
)
252 libs
.insert(0, 'wxc_d')
254 libs
.insert(0, 'wxc')
256 #----------------------------------------------------------------------
257 # Define the GLCanvas extension module
258 #----------------------------------------------------------------------
260 if not BUILD_GLCANVAS
:
261 wxext
.sources
= wxext
.sources
+ ['contrib/glcanvas/stub.cpp']
263 print 'Preparing GLCANVAS...'
264 location
= 'contrib/glcanvas'
265 swig_files
= ['glcanvas.i']
267 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
268 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
271 if os
.name
== 'posix':
272 if '-D__WXDEBUG__' in cflags
:
273 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
275 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
277 wxext
.sources
= wxext
.sources
+ swig_sources
278 wxext
.libraries
= wxext
.libraries
+ gl_libs
281 #----------------------------------------------------------------------
282 # Define the OGL extension module
283 #----------------------------------------------------------------------
287 wxext
.sources
= wxext
.sources
+ ['contrib/ogl/stub.cpp']
289 print 'Preparing OGL...'
290 location
= 'contrib/ogl'
291 OGLLOC
= location
+ '/contrib/src/ogl'
292 OGLINC
= location
+ '/contrib/include'
294 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
297 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
298 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
300 # make sure local copy of contrib files are up to date
302 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
303 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
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
,
321 wxext
.include_dirs
= wxext
.include_dirs
+ [OGLINC
]
323 #----------------------------------------------------------------------
324 # Define the STC extension module
325 #----------------------------------------------------------------------
329 wxext
.sources
= wxext
.sources
+ ['contrib/stc/stub.cpp']
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'
337 # make sure local copy of contrib files are up to date
339 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
340 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
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
],
347 swig_deps
+ [STC_H
+'/stc.h'])
349 # copy a project specific py module to the main package dir
350 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
352 # add some include dirs to the standard set
353 stc_includes
= [ '%s/scintilla/include' % STCLOC
,
354 '%s/scintilla/src' % STCLOC
,
357 # and some macro definitions
358 stc_defines
= [ ('__WX__', None),
359 ('SCI_LEXER', None) ]
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
,
391 '%s/PlatWX.cpp' % STCLOC
,
392 '%s/ScintillaWX.cpp' % STCLOC
,
393 '%s/stc.cpp' % STCLOC
,
396 wxext
.include_dirs
= wxext
.include_dirs
+ stc_includes
397 wxext
.define_macros
= wxext
.define_macros
+ stc_defines
401 #----------------------------------------------------------------------
402 # Do the Setup/Build/Install/Whatever
403 #----------------------------------------------------------------------
407 description
= DESCRIPTION
,
408 long_description
= LONG_DESCRIPTION
,
410 author_email
= AUTHOR_EMAIL
,
416 PKGDIR
+'.lib.editor',
419 ext_package
= PKGDIR
,
420 ext_modules
= wxpExtensions
,
427 #----------------------------------------------------------------------
428 #----------------------------------------------------------------------
429 #----------------------------------------------------------------------
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.
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
441 ## from my_install_data import *
443 ## Add this to the setup() call
444 ## # Overridden command classes
445 ## cmdclass = {'install_data': my_install_data},
446 ## # non python files of examples
449 ## base_dir='install_lib',
450 ## copy_to = 'wxPython',
452 ## template=[ 'graft demo',
453 ## 'global-exclude CVS/*'
461 #----------------------------------------------------------------------
462 #----------------------------------------------------------------------
463 #----------------------------------------------------------------------
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.
471 ## if BUILD_GLCANVAS:
472 ## print 'Preparing GLCANVAS...'
473 ## location = 'contrib/glcanvas'
474 ## swig_files = ['glcanvas.i']
476 ## swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
477 ## USE_SWIG, swig_force, swig_args)
480 ## if os.name == 'posix':
481 ## if '-D__WXDEBUG__' in cflags:
482 ## gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
484 ## gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
486 ## ext = Extension('glcanvasc',
489 ## include_dirs = includes,
490 ## define_macros = defines,
492 ## library_dirs = libdirs,
493 ## libraries = libs + gl_libs,
495 ## extra_compile_args = cflags,
496 ## extra_link_args = lflags,
499 ## wxpExtensions.append(ext)
504 ## print 'Preparing OGL...'
505 ## location = 'contrib/ogl'
506 ## OGLLOC = location + '/contrib/src/ogl'
507 ## OGLINC = location + '/contrib/include'
509 ## swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
512 ## swig_sources = run_swig(swig_files, location, '', PKGDIR,
513 ## USE_SWIG, swig_force, swig_args)
515 ## # make sure local copy of contrib files are up to date
517 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
518 ## contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
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,
535 ## include_dirs = [OGLINC] + includes,
536 ## define_macros = defines,
538 ## library_dirs = libdirs,
541 ## extra_compile_args = cflags,
542 ## extra_link_args = lflags,
545 ## wxpExtensions.append(ext)
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'
556 ## # make sure local copy of contrib files are up to date
558 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
559 ## contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
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],
568 ## # copy a project specific py module to the main package dir
569 ## copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
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)
577 ## # and some macro definitions
578 ## stc_defines = defines[:]
579 ## stc_defines.append( ('__WX__', None) )
580 ## stc_defines.append( ('SCI_LEXER', None) )
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,
611 ## '%s/PlatWX.cpp' % STCLOC,
612 ## '%s/ScintillaWX.cpp' % STCLOC,
613 ## '%s/stc.cpp' % STCLOC,
616 ## include_dirs = stc_includes,
617 ## define_macros = stc_defines,
619 ## library_dirs = libdirs,
622 ## extra_compile_args = cflags,
623 ## extra_link_args = lflags,
626 ## wxpExtensions.append(ext)