]>
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
76 bcpp_compiling
= '-c' in sys
.argv
and 'my_bcpp' in sys
.argv
# Bad heuristic
79 print "Compiling wxPython by Borland C/C++ Compiler"
81 WXBCPPLIBVER
= string
.replace(WXDLLVER
,"_","")
82 # Version part of BCPP build LIBRARY name
83 WXDLLVER
="" # no dll ver path avaible
86 #----------------------------------------------------------------------
87 # Check for build flags on the command line
88 #----------------------------------------------------------------------
90 for flag
in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
91 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID', ]:
92 for x
in range(len(sys
.argv
)):
93 if string
.find(sys
.argv
[x
], flag
) == 0:
94 pos
= string
.find(sys
.argv
[x
], '=') + 1
96 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
99 for option
in ['WX_CONFIG', 'WXDLLVER', ]:
100 for x
in range(len(sys
.argv
)):
101 if string
.find(sys
.argv
[x
], option
) == 0:
102 pos
= string
.find(sys
.argv
[x
], '=') + 1
104 vars()[option
] = sys
.argv
[x
][pos
:]
107 sys
.argv
= filter(None, sys
.argv
)
115 #----------------------------------------------------------------------
116 # Setup some platform specific stuff
117 #----------------------------------------------------------------------
120 # Set compile flags and such for MSVC. These values are derived
121 # from the wxWindows makefiles for MSVC, others will probably
123 WXDIR
= os
.environ
['WXWIN']
135 os
.path
.join(WXDIR
, 'include'),
138 defines
= [ ('WIN32', None), # Some of these are no longer
139 ('__WIN32__', None), # necessary. Anybody know which?
141 ('__WINDOWS__', None),
142 ('WINVER', '0x0400'),
149 ('SWIG_GLOBAL', None),
150 ('HAVE_CONFIG_H', None),
151 ('WXP_USE_THREAD', '1'),
154 if bcpp_compiling
: # overwrite it
157 ('WINVER', '0x0400'),
162 ('SWIG_GLOBAL', None),
163 ('HAVE_CONFIG_H', None),
164 ('WXP_USE_THREAD', '1'),
166 ('WXUSE_DEFINE','1'),
171 if not FINAL
or HYBRID
:
172 defines
.append( ('__WXDEBUG__', None) )
174 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
177 wxdll
= 'wx' + WXDLLVER
179 wxdll
= 'wx' + WXDLLVER
+ 'h'
181 wxdll
= 'wx' + WXDLLVER
+ 'd'
186 libs
= ['wx'+WXBCPPLIBVER
]
188 libs
= libs
+ ['kernel32', 'user32', 'gdi32', 'comdlg32',
189 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
190 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
191 'advapi32', 'wsock32']
194 cflags
= ['/GX-'] # workaround for internal compiler error in MSVC 5
198 if bcpp_compiling
: # overwrite it
199 cflags
= ['-5', '-VF', ### To supplort MSVC spurious semicolons in the class scope
200 ### else, all semicolons at the end of all DECLARE_...CALLBACK... macros must be eliminated
201 '-Hc', '-H='+WXDIR
+'\src\msw\wx32.csm',
202 '@'+WXDIR
+'\src\msw\wxwin32.cfg'
206 if not FINAL
and HYBRID
and not bcpp_compiling
:
207 cflags
= cflags
+ ['/Od', '/Z7']
208 lflags
= ['/DEBUG', ]
210 elif bcpp_compiling
and not FINAL
:
211 cflags
= cflags
+ ['/Od', '/v', '/y']
212 lflags
= lflags
+ ['/v', ] ## '/PDB:NONE']
216 elif os
.name
== 'posix':
217 # Set flags for Unix type platforms
219 WXDIR
= '..' # assumes IN_CVS_TREE
220 WXPLAT
= '__WXGTK__' # and assumes GTK...
221 GENDIR
= 'gtk' # Need to allow for Motif eventually too
224 defines
= [('SWIG_GLOBAL', None),
225 ('HAVE_CONFIG_H', None),
226 ('WXP_USE_THREAD', '1'),
231 cflags
= os
.popen(WX_CONFIG
+ ' --cflags', 'r').read()[:-1] + ' ' + \
232 os
.popen('gtk-config --cflags', 'r').read()[:-1]
233 cflags
= string
.split(cflags
)
235 lflags
= os
.popen(WX_CONFIG
+ ' --libs', 'r').read()[:-1]
236 lflags
= string
.split(lflags
)
240 raise 'Sorry Charlie...'
243 #----------------------------------------------------------------------
244 # Check if the version file needs updated
245 #----------------------------------------------------------------------
247 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
248 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
252 #----------------------------------------------------------------------
254 #----------------------------------------------------------------------
257 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
258 '-I./src', '-D'+WXPLAT
]
259 swig_deps
= ['src/my_typemaps.i']
262 #----------------------------------------------------------------------
263 # Define the CORE extension module
264 #----------------------------------------------------------------------
267 print 'Preparing CORE...'
268 swig_files
= [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
269 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
270 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
271 'printfw.i', 'sizers.i', 'clip_dnd.i',
272 'filesys.i', 'streams.i',
273 ##'grid.i', 'html.i', 'htmlhelp.i', 'calendar.i', 'utils.i',
276 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
277 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
279 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
280 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
283 if IN_CVS_TREE
: # update the licence files
285 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
286 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
290 rc_file
= ['src/wxc.rc']
295 ext
= Extension('wxc', ['src/helpers.cpp',
297 ] + rc_file
+ swig_sources
,
299 include_dirs
= includes
,
300 define_macros
= defines
,
302 library_dirs
= libdirs
,
305 extra_compile_args
= cflags
,
306 extra_link_args
= lflags
,
308 wxpExtensions
.append(ext
)
311 # Extension for the grid module
312 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
313 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
314 ext
= Extension('gridc', swig_sources
,
315 include_dirs
= includes
,
316 define_macros
= defines
,
317 library_dirs
= libdirs
,
319 extra_compile_args
= cflags
,
320 extra_link_args
= lflags
,
322 wxpExtensions
.append(ext
)
325 # Extension for the html modules
326 swig_sources
= run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR
, PKGDIR
,
327 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
328 ext
= Extension('htmlc', swig_sources
,
329 include_dirs
= includes
,
330 define_macros
= defines
,
331 library_dirs
= libdirs
,
333 extra_compile_args
= cflags
,
334 extra_link_args
= lflags
,
336 wxpExtensions
.append(ext
)
339 # Extension for the utils module
340 swig_sources
= run_swig(['utils.i'], 'src', GENDIR
, PKGDIR
,
341 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
342 ext
= Extension('utilsc', swig_sources
,
343 include_dirs
= includes
,
344 define_macros
= defines
,
345 library_dirs
= libdirs
,
347 extra_compile_args
= cflags
,
348 extra_link_args
= lflags
,
350 wxpExtensions
.append(ext
)
353 # Extension for the calendar module
354 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
355 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
356 ext
= Extension('calendarc', swig_sources
,
357 include_dirs
= includes
,
358 define_macros
= defines
,
359 library_dirs
= libdirs
,
361 extra_compile_args
= cflags
,
362 extra_link_args
= lflags
,
364 wxpExtensions
.append(ext
)
367 #----------------------------------------------------------------------
368 # Define the GLCanvas extension module
369 #----------------------------------------------------------------------
371 if BUILD_GLCANVAS
or GL_ONLY
:
372 print 'Preparing GLCANVAS...'
373 location
= 'contrib/glcanvas'
374 swig_files
= ['glcanvas.i']
377 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
378 USE_SWIG
, swig_force
, swig_args
)
381 if os
.name
== 'posix':
382 if '-D__WXDEBUG__' in cflags
:
383 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
385 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
387 other_sources
= [location
+ '/msw/myglcanvas.cpp']
388 gl_libs
= ['opengl32', 'glu32']
391 ext
= Extension('glcanvasc',
392 swig_sources
+ other_sources
,
394 include_dirs
= includes
,
395 define_macros
= defines
,
397 library_dirs
= libdirs
,
398 libraries
= libs
+ gl_libs
,
400 extra_compile_args
= cflags
,
401 extra_link_args
= lflags
,
404 wxpExtensions
.append(ext
)
407 #----------------------------------------------------------------------
408 # Define the OGL extension module
409 #----------------------------------------------------------------------
411 if not GL_ONLY
and BUILD_OGL
:
412 print 'Preparing OGL...'
413 location
= 'contrib/ogl'
414 OGLLOC
= location
+ '/contrib/src/ogl'
415 OGLINC
= location
+ '/contrib/include'
417 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
420 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
421 USE_SWIG
, swig_force
, swig_args
)
423 # make sure local copy of contrib files are up to date
425 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
426 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
428 ext
= Extension('oglc', ['%s/basic.cpp' % OGLLOC
,
429 '%s/bmpshape.cpp' % OGLLOC
,
430 '%s/composit.cpp' % OGLLOC
,
431 '%s/divided.cpp' % OGLLOC
,
432 '%s/lines.cpp' % OGLLOC
,
433 '%s/misc.cpp' % OGLLOC
,
434 '%s/basic2.cpp' % OGLLOC
,
435 '%s/canvas.cpp' % OGLLOC
,
436 '%s/constrnt.cpp' % OGLLOC
,
437 '%s/drawn.cpp' % OGLLOC
,
438 '%s/mfutils.cpp' % OGLLOC
,
439 '%s/ogldiag.cpp' % OGLLOC
,
442 include_dirs
= [OGLINC
] + includes
,
443 define_macros
= defines
,
445 library_dirs
= libdirs
,
448 extra_compile_args
= cflags
,
449 extra_link_args
= lflags
,
452 wxpExtensions
.append(ext
)
456 #----------------------------------------------------------------------
457 # Define the STC extension module
458 #----------------------------------------------------------------------
460 if not GL_ONLY
and BUILD_STC
:
461 print 'Preparing STC...'
462 location
= 'contrib/stc'
463 STCLOC
= location
+ '/contrib/src/stc'
464 STCINC
= location
+ '/contrib/include'
465 STC_H
= location
+ '/contrib/include/wx/stc'
467 # make sure local copy of contrib files are up to date
469 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
470 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
473 swig_files
= ['stc_.i']
474 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
475 USE_SWIG
, swig_force
,
476 swig_args
+ ['-I'+STC_H
, '-I'+location
],
479 # copy a project specific py module to the main package dir
480 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
482 # add some include dirs to the standard set
483 stc_includes
= includes
[:]
484 stc_includes
.append('%s/scintilla/include' % STCLOC
)
485 stc_includes
.append('%s/scintilla/src' % STCLOC
)
486 stc_includes
.append(STCINC
)
488 # and some macro definitions
489 stc_defines
= defines
[:]
490 stc_defines
.append( ('__WX__', None) )
491 stc_defines
.append( ('SCI_LEXER', None) )
494 ext
= Extension('stc_c',
495 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
496 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
497 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
498 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
499 '%s/scintilla/src/Document.cxx' % STCLOC
,
500 '%s/scintilla/src/Editor.cxx' % STCLOC
,
501 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
502 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
503 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
504 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
505 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
506 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
507 '%s/scintilla/src/Style.cxx' % STCLOC
,
508 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
509 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
510 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
511 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
512 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
513 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
514 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
515 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
516 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
517 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
518 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
519 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
520 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
522 '%s/PlatWX.cpp' % STCLOC
,
523 '%s/ScintillaWX.cpp' % STCLOC
,
524 '%s/stc.cpp' % STCLOC
,
527 include_dirs
= stc_includes
,
528 define_macros
= stc_defines
,
530 library_dirs
= libdirs
,
533 extra_compile_args
= cflags
,
534 extra_link_args
= lflags
,
537 wxpExtensions
.append(ext
)
541 #----------------------------------------------------------------------
542 # Do the Setup/Build/Install/Whatever
543 #----------------------------------------------------------------------
545 if __name__
== "__main__":
549 description
= DESCRIPTION
,
550 long_description
= LONG_DESCRIPTION
,
552 author_email
= AUTHOR_EMAIL
,
558 PKGDIR
+'.lib.editor',
561 ext_package
= PKGDIR
,
562 ext_modules
= wxpExtensions
,
567 setup(name
= "wxPython-gl",
569 description
= "wxGLCanvas class for wxPython",
571 author_email
= AUTHOR_EMAIL
,
575 py_modules
= [ "wxPython.glcanvas" ],
577 ext_package
= PKGDIR
,
578 ext_modules
= wxpExtensions
,
584 #----------------------------------------------------------------------
585 #----------------------------------------------------------------------