]>
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']
157 if not FINAL
and HYBRID
:
158 cflags
= ['/Od', '/Z7']
159 lflags
= ['/DEBUG', ] ## '/PDB:NONE']
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', '-dnone',
203 '-I./src', '-D'+WXPLAT
]
205 swig_files
= [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
206 'misc.i', 'misc2.i', 'utils.i', 'gdi.i', 'mdi.i', 'controls.i',
207 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
208 'printfw.i', 'sizers.i', 'clip_dnd.i', 'grid.i', 'html.i',
209 'htmlhelp.i', 'calendar.i', 'filesys.i', 'streams.i'
212 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
213 USE_SWIG
, swig_force
, swig_args
)
215 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
216 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
219 if IN_CVS_TREE
: # update the licence files
221 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
222 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
226 rc_file
= ['src/wxc.rc']
231 wxext
= ext
= Extension('wxc', ['src/helpers.cpp',
233 ] + rc_file
+ swig_sources
,
235 include_dirs
= includes
,
236 define_macros
= defines
,
238 library_dirs
= libdirs
,
241 extra_compile_args
= cflags
,
242 extra_link_args
= lflags
,
246 wxpExtensions
.append(ext
)
251 libs
.insert(0, 'wxc_d')
253 libs
.insert(0, 'wxc')
255 #----------------------------------------------------------------------
256 # Define the GLCanvas extension module
257 #----------------------------------------------------------------------
259 if not BUILD_GLCANVAS
:
260 wxext
.sources
= wxext
.sources
+ ['contrib/glcanvas/stub.cpp']
262 print 'Preparing GLCANVAS...'
263 location
= 'contrib/glcanvas'
264 swig_files
= ['glcanvas.i']
266 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
267 USE_SWIG
, swig_force
, swig_args
)
270 if os
.name
== 'posix':
271 if '-D__WXDEBUG__' in cflags
:
272 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
274 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
276 wxext
.sources
= wxext
.sources
+ swig_sources
277 wxext
.libraries
= wxext
.libraries
+ gl_libs
280 #----------------------------------------------------------------------
281 # Define the OGL extension module
282 #----------------------------------------------------------------------
286 wxext
.sources
= wxext
.sources
+ ['contrib/ogl/stub.cpp']
288 print 'Preparing OGL...'
289 location
= 'contrib/ogl'
290 OGLLOC
= location
+ '/contrib/src/ogl'
291 OGLINC
= location
+ '/contrib/include'
293 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
296 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
297 USE_SWIG
, swig_force
, swig_args
)
299 # make sure local copy of contrib files are up to date
301 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
302 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
304 # add items to the core extension module definition
305 wxext
.sources
= wxext
.sources
+ [location
+ '/oglhelpers.cpp',
306 '%s/basic.cpp' % OGLLOC
,
307 '%s/bmpshape.cpp' % OGLLOC
,
308 '%s/composit.cpp' % OGLLOC
,
309 '%s/divided.cpp' % OGLLOC
,
310 '%s/lines.cpp' % OGLLOC
,
311 '%s/misc.cpp' % OGLLOC
,
312 '%s/basic2.cpp' % OGLLOC
,
313 '%s/canvas.cpp' % OGLLOC
,
314 '%s/constrnt.cpp' % OGLLOC
,
315 '%s/drawn.cpp' % OGLLOC
,
316 '%s/mfutils.cpp' % OGLLOC
,
317 '%s/ogldiag.cpp' % OGLLOC
,
320 wxext
.include_dirs
= wxext
.include_dirs
+ [OGLINC
]
322 #----------------------------------------------------------------------
323 # Define the STC extension module
324 #----------------------------------------------------------------------
328 wxext
.sources
= wxext
.sources
+ ['contrib/stc/stub.cpp']
330 print 'Preparing STC...'
331 location
= 'contrib/stc'
332 STCLOC
= location
+ '/contrib/src/stc'
333 STCINC
= location
+ '/contrib/include'
334 STC_H
= location
+ '/contrib/include/wx/stc'
336 # make sure local copy of contrib files are up to date
338 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
339 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
342 swig_files
= ['stc_.i']
343 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
344 USE_SWIG
, swig_force
,
345 swig_args
+ ['-I'+STC_H
, '-I'+location
],
348 # copy a project specific py module to the main package dir
349 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
351 # add some include dirs to the standard set
352 stc_includes
= [ '%s/scintilla/include' % STCLOC
,
353 '%s/scintilla/src' % STCLOC
,
356 # and some macro definitions
357 stc_defines
= [ ('__WX__', None),
358 ('SCI_LEXER', None) ]
361 # add items to the core extension module definition
362 wxext
.sources
= wxext
.sources
+ [
363 '%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
364 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
365 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
366 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
367 '%s/scintilla/src/Document.cxx' % STCLOC
,
368 '%s/scintilla/src/Editor.cxx' % STCLOC
,
369 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
370 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
371 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
372 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
373 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
374 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
375 '%s/scintilla/src/Style.cxx' % STCLOC
,
376 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
377 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
378 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
379 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
380 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
381 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
382 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
383 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
384 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
385 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
386 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
387 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
388 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
390 '%s/PlatWX.cpp' % STCLOC
,
391 '%s/ScintillaWX.cpp' % STCLOC
,
392 '%s/stc.cpp' % STCLOC
,
395 wxext
.include_dirs
= wxext
.include_dirs
+ stc_includes
396 wxext
.define_macros
= wxext
.define_macros
+ stc_defines
400 #----------------------------------------------------------------------
401 # Do the Setup/Build/Install/Whatever
402 #----------------------------------------------------------------------
406 description
= DESCRIPTION
,
407 long_description
= LONG_DESCRIPTION
,
409 author_email
= AUTHOR_EMAIL
,
415 PKGDIR
+'.lib.editor',
418 ext_package
= PKGDIR
,
419 ext_modules
= wxpExtensions
,
426 #----------------------------------------------------------------------
427 #----------------------------------------------------------------------
428 #----------------------------------------------------------------------
430 # The pre-distutils binary distributions of wxPython included the demo
431 # as a subdirectory of the package dir. This doesn't really make sense
432 # for Linux/Unix platforms as it's not part of the package, and the user
433 # may want to tweak and learn without having to become root first.
435 # For now I am going to start distributing the demo as a separate tarball,
436 # but if I ever want to go back to the old way, this is how to do it the
440 ## from my_install_data import *
442 ## Add this to the setup() call
443 ## # Overridden command classes
444 ## cmdclass = {'install_data': my_install_data},
445 ## # non python files of examples
448 ## base_dir='install_lib',
449 ## copy_to = 'wxPython',
451 ## template=[ 'graft demo',
452 ## 'global-exclude CVS/*'
460 #----------------------------------------------------------------------
461 #----------------------------------------------------------------------
462 #----------------------------------------------------------------------
464 # Originally I was building separate extension module .so's for the
465 # CORE and the various contribs. Because of shared library issues I've
466 # decided to combine things into one .so as implemented above, but as
467 # I'm still not entirely convinced that this is the right thing to do
468 # I will keep the old code around for a while, but commented out below.
470 ## if BUILD_GLCANVAS:
471 ## print 'Preparing GLCANVAS...'
472 ## location = 'contrib/glcanvas'
473 ## swig_files = ['glcanvas.i']
475 ## swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
476 ## USE_SWIG, swig_force, swig_args)
479 ## if os.name == 'posix':
480 ## if '-D__WXDEBUG__' in cflags:
481 ## gl_libs = ['wx_gtkd_gl', 'GL', 'GLU']
483 ## gl_libs = ['wx_gtk_gl', 'GL', 'GLU']
485 ## ext = Extension('glcanvasc',
488 ## include_dirs = includes,
489 ## define_macros = defines,
491 ## library_dirs = libdirs,
492 ## libraries = libs + gl_libs,
494 ## extra_compile_args = cflags,
495 ## extra_link_args = lflags,
498 ## wxpExtensions.append(ext)
503 ## print 'Preparing OGL...'
504 ## location = 'contrib/ogl'
505 ## OGLLOC = location + '/contrib/src/ogl'
506 ## OGLINC = location + '/contrib/include'
508 ## swig_files = ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
511 ## swig_sources = run_swig(swig_files, location, '', PKGDIR,
512 ## USE_SWIG, swig_force, swig_args)
514 ## # make sure local copy of contrib files are up to date
516 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/ogl', OGLINC+'/wx/ogl')
517 ## contrib_copy_tree(WXDIR + '/contrib/src/ogl', OGLLOC)
519 ## ext = Extension('oglc', [location + '/oglhelpers.cpp',
520 ## '%s/basic.cpp' % OGLLOC,
521 ## '%s/bmpshape.cpp' % OGLLOC,
522 ## '%s/composit.cpp' % OGLLOC,
523 ## '%s/divided.cpp' % OGLLOC,
524 ## '%s/lines.cpp' % OGLLOC,
525 ## '%s/misc.cpp' % OGLLOC,
526 ## '%s/basic2.cpp' % OGLLOC,
527 ## '%s/canvas.cpp' % OGLLOC,
528 ## '%s/constrnt.cpp' % OGLLOC,
529 ## '%s/drawn.cpp' % OGLLOC,
530 ## '%s/mfutils.cpp' % OGLLOC,
531 ## '%s/ogldiag.cpp' % OGLLOC,
534 ## include_dirs = [OGLINC] + includes,
535 ## define_macros = defines,
537 ## library_dirs = libdirs,
540 ## extra_compile_args = cflags,
541 ## extra_link_args = lflags,
544 ## wxpExtensions.append(ext)
549 ## print 'Preparing STC...'
550 ## location = 'contrib/stc'
551 ## STCLOC = location + '/contrib/src/stc'
552 ## STCINC = location + '/contrib/include'
553 ## STC_H = location + '/contrib/include/wx/stc'
555 ## # make sure local copy of contrib files are up to date
557 ## contrib_copy_tree(WXDIR + '/contrib/include/wx/stc', STCINC+'/wx/stc')
558 ## contrib_copy_tree(WXDIR + '/contrib/src/stc', STCLOC)
561 ## swig_files = ['stc_.i']
562 ## swig_sources = run_swig(swig_files, location, '', PKGDIR,
563 ## USE_SWIG, swig_force,
564 ## swig_args + ['-I'+STC_H, '-I'+location],
567 ## # copy a project specific py module to the main package dir
568 ## copy_file(location+'/stc.py', PKGDIR, update=1, verbose=1)
570 ## # add some include dirs to the standard set
571 ## stc_includes = includes[:]
572 ## stc_includes.append('%s/scintilla/include' % STCLOC)
573 ## stc_includes.append('%s/scintilla/src' % STCLOC)
574 ## stc_includes.append(STCINC)
576 ## # and some macro definitions
577 ## stc_defines = defines[:]
578 ## stc_defines.append( ('__WX__', None) )
579 ## stc_defines.append( ('SCI_LEXER', None) )
582 ## ext = Extension('stc_c',
583 ## ['%s/scintilla/src/AutoComplete.cxx' % STCLOC,
584 ## '%s/scintilla/src/CallTip.cxx' % STCLOC,
585 ## '%s/scintilla/src/CellBuffer.cxx' % STCLOC,
586 ## '%s/scintilla/src/ContractionState.cxx' % STCLOC,
587 ## '%s/scintilla/src/Document.cxx' % STCLOC,
588 ## '%s/scintilla/src/Editor.cxx' % STCLOC,
589 ## '%s/scintilla/src/Indicator.cxx' % STCLOC,
590 ## '%s/scintilla/src/KeyMap.cxx' % STCLOC,
591 ## '%s/scintilla/src/KeyWords.cxx' % STCLOC,
592 ## '%s/scintilla/src/LineMarker.cxx' % STCLOC,
593 ## '%s/scintilla/src/PropSet.cxx' % STCLOC,
594 ## '%s/scintilla/src/ScintillaBase.cxx' % STCLOC,
595 ## '%s/scintilla/src/Style.cxx' % STCLOC,
596 ## '%s/scintilla/src/ViewStyle.cxx' % STCLOC,
597 ## '%s/scintilla/src/LexCPP.cxx' % STCLOC,
598 ## '%s/scintilla/src/LexHTML.cxx' % STCLOC,
599 ## '%s/scintilla/src/LexLua.cxx' % STCLOC,
600 ## '%s/scintilla/src/LexOthers.cxx' % STCLOC,
601 ## '%s/scintilla/src/LexPerl.cxx' % STCLOC,
602 ## '%s/scintilla/src/LexPython.cxx' % STCLOC,
603 ## '%s/scintilla/src/LexSQL.cxx' % STCLOC,
604 ## '%s/scintilla/src/LexVB.cxx' % STCLOC,
605 ## '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC,
606 ## '%s/scintilla/src/UniConversion.cxx' % STCLOC,
607 ## '%s/scintilla/src/WindowAccessor.cxx' % STCLOC,
608 ## '%s/scintilla/src/PosRegExp.cxx' % STCLOC,
610 ## '%s/PlatWX.cpp' % STCLOC,
611 ## '%s/ScintillaWX.cpp' % STCLOC,
612 ## '%s/stc.cpp' % STCLOC,
615 ## include_dirs = stc_includes,
616 ## define_macros = stc_defines,
618 ## library_dirs = libdirs,
621 ## extra_compile_args = cflags,
622 ## extra_link_args = lflags,
625 ## wxpExtensions.append(ext)