]>
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']
113 os
.path
.join(WXDIR
, 'include'),
116 defines
= [ ('WIN32', None), # Some of these are no longer
117 ('__WIN32__', None), # necessary. Anybody know which?
119 ('__WINDOWS__', None),
120 ('WINVER', '0x0400'),
127 ('SWIG_GLOBAL', None),
128 ('HAVE_CONFIG_H', None),
129 ('WXP_USE_THREAD', '1'),
132 if not FINAL
or HYBRID
:
133 defines
.append( ('__WXDEBUG__', None) )
135 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
138 wxdll
= 'wx' + WXDLLVER
140 wxdll
= 'wx' + WXDLLVER
+ 'h'
142 wxdll
= 'wx' + WXDLLVER
+ 'd'
145 libs
= [wxdll
, 'kernel32', 'user32', 'gdi32', 'comdlg32',
146 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
147 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
148 'advapi32', 'wsock32']
150 cflags
= ['/GX-'] # workaround for internal compiler error in MSVC 5
153 if not FINAL
and HYBRID
:
154 cflags
= cflags
+ ['/Od', '/Z7']
155 lflags
= ['/DEBUG', ]
158 elif os
.name
== 'posix':
159 # Set flags for Unix type platforms
161 WXDIR
= '..' # assumes IN_CVS_TREE
162 WXPLAT
= '__WXGTK__' # and assumes GTK...
163 GENDIR
= 'gtk' # Need to allow for Motif eventually too
166 defines
= [('SWIG_GLOBAL', None),
167 ('HAVE_CONFIG_H', None),
168 ('WXP_USE_THREAD', '1'),
173 cflags
= os
.popen('wx-config --cflags', 'r').read()[:-1] + ' ' + \
174 os
.popen('gtk-config --cflags', 'r').read()[:-1]
175 cflags
= string
.split(cflags
)
177 lflags
= os
.popen('wx-config --libs', 'r').read()[:-1]
178 lflags
= string
.split(lflags
)
182 raise 'Sorry Charlie...'
185 #----------------------------------------------------------------------
186 # Check if the version file needs updated
187 #----------------------------------------------------------------------
189 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
190 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
192 #----------------------------------------------------------------------
193 # Define the CORE extension module
194 #----------------------------------------------------------------------
196 print 'Preparing CORE...'
198 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
199 '-I./src', '-D'+WXPLAT
]
200 swig_deps
= ['src/my_typemaps.i']
202 swig_files
= [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
203 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
204 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
205 'printfw.i', 'sizers.i', 'clip_dnd.i',
206 'filesys.i', 'streams.i',
207 ##'grid.i', 'html.i', 'htmlhelp.i', 'calendar.i', 'utils.i',
210 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
211 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
213 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
214 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
217 if IN_CVS_TREE
: # update the licence files
219 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
220 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
224 rc_file
= ['src/wxc.rc']
229 ext
= Extension('wxc', ['src/helpers.cpp',
231 ] + rc_file
+ swig_sources
,
233 include_dirs
= includes
,
234 define_macros
= defines
,
236 library_dirs
= libdirs
,
239 extra_compile_args
= cflags
,
240 extra_link_args
= lflags
,
242 wxpExtensions
.append(ext
)
245 # Extension for the grid module
246 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
247 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
248 ext
= Extension('gridc', swig_sources
,
249 include_dirs
= includes
,
250 define_macros
= defines
,
251 library_dirs
= libdirs
,
253 extra_compile_args
= cflags
,
254 extra_link_args
= lflags
,
256 wxpExtensions
.append(ext
)
259 # Extension for the html modules
260 swig_sources
= run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR
, PKGDIR
,
261 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
262 ext
= Extension('htmlc', swig_sources
,
263 include_dirs
= includes
,
264 define_macros
= defines
,
265 library_dirs
= libdirs
,
267 extra_compile_args
= cflags
,
268 extra_link_args
= lflags
,
270 wxpExtensions
.append(ext
)
273 # Extension for the utils module
274 swig_sources
= run_swig(['utils.i'], 'src', GENDIR
, PKGDIR
,
275 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
276 ext
= Extension('utilsc', swig_sources
,
277 include_dirs
= includes
,
278 define_macros
= defines
,
279 library_dirs
= libdirs
,
281 extra_compile_args
= cflags
,
282 extra_link_args
= lflags
,
284 wxpExtensions
.append(ext
)
287 # Extension for the calendar module
288 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
289 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
290 ext
= Extension('calendarc', swig_sources
,
291 include_dirs
= includes
,
292 define_macros
= defines
,
293 library_dirs
= libdirs
,
295 extra_compile_args
= cflags
,
296 extra_link_args
= lflags
,
298 wxpExtensions
.append(ext
)
301 #----------------------------------------------------------------------
302 # Define the GLCanvas extension module
303 #----------------------------------------------------------------------
306 print 'Preparing GLCANVAS...'
307 location
= 'contrib/glcanvas'
308 swig_files
= ['glcanvas.i']
310 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
311 USE_SWIG
, swig_force
, swig_args
)
314 if os
.name
== 'posix':
315 if '-D__WXDEBUG__' in cflags
:
316 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
318 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
320 ext
= Extension('glcanvasc',
323 include_dirs
= includes
,
324 define_macros
= defines
,
326 library_dirs
= libdirs
,
327 libraries
= libs
+ gl_libs
,
329 extra_compile_args
= cflags
,
330 extra_link_args
= lflags
,
333 wxpExtensions
.append(ext
)
336 #----------------------------------------------------------------------
337 # Define the OGL extension module
338 #----------------------------------------------------------------------
342 print 'Preparing OGL...'
343 location
= 'contrib/ogl'
344 OGLLOC
= location
+ '/contrib/src/ogl'
345 OGLINC
= location
+ '/contrib/include'
347 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
350 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
351 USE_SWIG
, swig_force
, swig_args
)
353 # make sure local copy of contrib files are up to date
355 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
356 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
358 ext
= Extension('oglc', ['%s/basic.cpp' % OGLLOC
,
359 '%s/bmpshape.cpp' % OGLLOC
,
360 '%s/composit.cpp' % OGLLOC
,
361 '%s/divided.cpp' % OGLLOC
,
362 '%s/lines.cpp' % OGLLOC
,
363 '%s/misc.cpp' % OGLLOC
,
364 '%s/basic2.cpp' % OGLLOC
,
365 '%s/canvas.cpp' % OGLLOC
,
366 '%s/constrnt.cpp' % OGLLOC
,
367 '%s/drawn.cpp' % OGLLOC
,
368 '%s/mfutils.cpp' % OGLLOC
,
369 '%s/ogldiag.cpp' % OGLLOC
,
372 include_dirs
= [OGLINC
] + includes
,
373 define_macros
= defines
,
375 library_dirs
= libdirs
,
378 extra_compile_args
= cflags
,
379 extra_link_args
= lflags
,
382 wxpExtensions
.append(ext
)
386 #----------------------------------------------------------------------
387 # Define the STC extension module
388 #----------------------------------------------------------------------
391 print 'Preparing STC...'
392 location
= 'contrib/stc'
393 STCLOC
= location
+ '/contrib/src/stc'
394 STCINC
= location
+ '/contrib/include'
395 STC_H
= location
+ '/contrib/include/wx/stc'
397 # make sure local copy of contrib files are up to date
399 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
400 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
403 swig_files
= ['stc_.i']
404 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
405 USE_SWIG
, swig_force
,
406 swig_args
+ ['-I'+STC_H
, '-I'+location
],
409 # copy a project specific py module to the main package dir
410 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
412 # add some include dirs to the standard set
413 stc_includes
= includes
[:]
414 stc_includes
.append('%s/scintilla/include' % STCLOC
)
415 stc_includes
.append('%s/scintilla/src' % STCLOC
)
416 stc_includes
.append(STCINC
)
418 # and some macro definitions
419 stc_defines
= defines
[:]
420 stc_defines
.append( ('__WX__', None) )
421 stc_defines
.append( ('SCI_LEXER', None) )
424 ext
= Extension('stc_c',
425 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
426 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
427 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
428 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
429 '%s/scintilla/src/Document.cxx' % STCLOC
,
430 '%s/scintilla/src/Editor.cxx' % STCLOC
,
431 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
432 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
433 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
434 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
435 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
436 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
437 '%s/scintilla/src/Style.cxx' % STCLOC
,
438 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
439 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
440 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
441 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
442 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
443 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
444 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
445 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
446 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
447 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
448 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
449 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
450 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
452 '%s/PlatWX.cpp' % STCLOC
,
453 '%s/ScintillaWX.cpp' % STCLOC
,
454 '%s/stc.cpp' % STCLOC
,
457 include_dirs
= stc_includes
,
458 define_macros
= stc_defines
,
460 library_dirs
= libdirs
,
463 extra_compile_args
= cflags
,
464 extra_link_args
= lflags
,
467 wxpExtensions
.append(ext
)
471 #----------------------------------------------------------------------
472 # Do the Setup/Build/Install/Whatever
473 #----------------------------------------------------------------------
477 description
= DESCRIPTION
,
478 long_description
= LONG_DESCRIPTION
,
480 author_email
= AUTHOR_EMAIL
,
486 PKGDIR
+'.lib.editor',
489 ext_package
= PKGDIR
,
490 ext_modules
= wxpExtensions
,
497 #----------------------------------------------------------------------
498 #----------------------------------------------------------------------
499 #----------------------------------------------------------------------
501 # The pre-distutils binary distributions of wxPython included the demo
502 # as a subdirectory of the package dir. This doesn't really make sense
503 # for Linux/Unix platforms as it's not part of the package, and the user
504 # may want to tweak and learn without having to become root first.
506 # For now I am going to start distributing the demo as a separate tarball,
507 # but if I ever want to go back to the old way, this is how to do it the
511 ## from my_install_data import *
513 ## Add this to the setup() call
514 ## # Overridden command classes
515 ## cmdclass = {'install_data': my_install_data},
516 ## # non python files of examples
519 ## base_dir='install_lib',
520 ## copy_to = 'wxPython',
522 ## template=[ 'graft demo',
523 ## 'global-exclude CVS/*'
531 #----------------------------------------------------------------------
532 #----------------------------------------------------------------------
533 #----------------------------------------------------------------------
534 ## if not BUILD_GLCANVAS:
535 ## wxext.sources = wxext.sources + ['contrib/glcanvas/stub.cpp']
537 ## print 'Preparing GLCANVAS...'
538 ## location = 'contrib/glcanvas'
539 ## swig_files = ['glcanvas.i']
541 ## swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
542 ## USE_SWIG, swig_force, swig_args, swig_deps)
545 ## if os.name == 'posix':
546 ## if '-D__WXDEBUG__' in cflags:
547 ## gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
549 ## gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
551 ## wxext.sources = wxext.sources + swig_sources
552 ## wxext.libraries = wxext.libraries + gl_libs
556 ## wxext.sources = wxext.sources + ['contrib/ogl/stub.cpp']
558 ## print 'Preparing OGL...'
559 ## location = 'contrib/ogl'
560 ## OGLLOC = location + '/contrib/src/ogl'
561 ## OGLINC = location + '/contrib/include'
563 ## swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
566 ## swig_sources = run_swig(swig_files, location, '', PKGDIR,
567 ## USE_SWIG, swig_force, swig_args, swig_deps)
569 ## # make sure local copy of contrib files are up to date
571 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
572 ## contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
574 ## # add items to the core extension module definition
575 ## wxext.sources = wxext.sources + [location + '/oglhelpers.cpp',
576 ## '%s/basic.cpp' % OGLLOC,
577 ## '%s/bmpshape.cpp' % OGLLOC,
578 ## '%s/composit.cpp' % OGLLOC,
579 ## '%s/divided.cpp' % OGLLOC,
580 ## '%s/lines.cpp' % OGLLOC,
581 ## '%s/misc.cpp' % OGLLOC,
582 ## '%s/basic2.cpp' % OGLLOC,
583 ## '%s/canvas.cpp' % OGLLOC,
584 ## '%s/constrnt.cpp' % OGLLOC,
585 ## '%s/drawn.cpp' % OGLLOC,
586 ## '%s/mfutils.cpp' % OGLLOC,
587 ## '%s/ogldiag.cpp' % OGLLOC,
590 ## wxext.include_dirs = wxext.include_dirs + [OGLINC]
596 ## wxext.sources = wxext.sources + ['contrib/stc/stub.cpp']
598 ## print 'Preparing STC...'
599 ## location = 'contrib/stc'
600 ## STCLOC = location + '/contrib/src/stc'
601 ## STCINC = location + '/contrib/include'
602 ## STC_H = location + '/contrib/include/wx/stc'
604 ## # make sure local copy of contrib files are up to date
606 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
607 ## contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
610 ## swig_files = ['stc_.i']
611 ## swig_sources = run_swig(swig_files, location, '', PKGDIR,
612 ## USE_SWIG, swig_force,
613 ## swig_args + ['-I'+STC_H, '-I'+location],
614 ## swig_deps + [STC_H+'/stc.h'])
616 ## # copy a project specific py module to the main package dir
617 ## copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
619 ## # add some include dirs to the standard set
620 ## stc_includes = [ '%s/scintilla/include' % STCLOC,
621 ## '%s/scintilla/src' % STCLOC,
624 ## # and some macro definitions
625 ## stc_defines = [ ('__WX__', None),
626 ## ('SCI_LEXER', None) ]
629 ## # add items to the core extension module definition
630 ## wxext.sources = wxext.sources + [
631 ## '%s/scintilla/src/AutoComplete.cxx' % STCLOC,
632 ## '%s/scintilla/src/CallTip.cxx' % STCLOC,
633 ## '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
634 ## '%s/scintilla/src/ContractionState.cxx' % STCLOC,
635 ## '%s/scintilla/src/Document.cxx' % STCLOC,
636 ## '%s/scintilla/src/Editor.cxx' % STCLOC,
637 ## '%s/scintilla/src/Indicator.cxx' % STCLOC,
638 ## '%s/scintilla/src/KeyMap.cxx' % STCLOC,
639 ## '%s/scintilla/src/KeyWords.cxx' % STCLOC,
640 ## '%s/scintilla/src/LineMarker.cxx' % STCLOC,
641 ## '%s/scintilla/src/PropSet.cxx' % STCLOC,
642 ## '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
643 ## '%s/scintilla/src/Style.cxx' % STCLOC,
644 ## '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
645 ## '%s/scintilla/src/LexCPP.cxx' % STCLOC,
646 ## '%s/scintilla/src/LexHTML.cxx' % STCLOC,
647 ## '%s/scintilla/src/LexLua.cxx' % STCLOC,
648 ## '%s/scintilla/src/LexOthers.cxx' % STCLOC,
649 ## '%s/scintilla/src/LexPerl.cxx' % STCLOC,
650 ## '%s/scintilla/src/LexPython.cxx' % STCLOC,
651 ## '%s/scintilla/src/LexSQL.cxx' % STCLOC,
652 ## '%s/scintilla/src/LexVB.cxx' % STCLOC,
653 ## '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
654 ## '%s/scintilla/src/UniConversion.cxx' % STCLOC,
655 ## '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
656 ## '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
658 ## '%s/PlatWX.cpp' % STCLOC,
659 ## '%s/ScintillaWX.cpp' % STCLOC,
660 ## '%s/stc.cpp' % STCLOC,
663 ## wxext.include_dirs = wxext.include_dirs + stc_includes
664 ## wxext.define_macros = wxext.define_macros + stc_defines