]>
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 BUILD_IEWIN
= 0 # Internet Explorer wrapper (experimental)
36 CORE_ONLY
= 0 # if true, don't build any of the above
37 GL_ONLY
= 0 # Only used when making the -gl RPM. See the "b" script
38 # for the ugly details
40 USE_SWIG
= 0 # Should we actually execute SWIG, or just use the
41 # files already in the distribution?
43 IN_CVS_TREE
= 0 # Set to true if building in a full wxWindows CVS
44 # tree, otherwise will assume all needed files are
45 # available in the wxPython source distribution
47 WX_CONFIG
= "wx-config" # Usually you shouldn't need to touch this,
48 # but you can set it to pass an alternate
49 # version of wx-config or alternate flags,
50 # eg. as required by the .deb in-tree build.
52 # Some MSW build settings
54 FINAL
= 1 # Mirrors use of same flag in wx makefiles,
55 # (0 or 1 only) should probably find a way to
58 HYBRID
= 0 # If set and not debug or FINAL, then build a
59 # hybrid extension that can be used by the
60 # non-debug version of python, but contains
61 # debugging symbols for wxWindows and wxPython.
62 # wxWindows must have been built with /MD, not /MDd
63 # (using FINAL=hybrid will do it.)
65 WXDLLVER
= '23_0' # Version part of DLL name
68 #----------------------------------------------------------------------
70 #----------------------------------------------------------------------
75 force
= '--force' in sys
.argv
or '-f' in sys
.argv
76 debug
= '--debug' in sys
.argv
or '-g' in sys
.argv
78 bcpp_compiling
= '-c' in sys
.argv
and 'my_bcpp' in sys
.argv
# Bad heuristic
81 print "Compiling wxPython by Borland C/C++ Compiler"
83 WXBCPPLIBVER
= string
.replace(WXDLLVER
,"_","")
84 # Version part of BCPP build LIBRARY name
85 WXDLLVER
="" # no dll ver path avaible
88 #----------------------------------------------------------------------
89 # Check for build flags on the command line
90 #----------------------------------------------------------------------
92 for flag
in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
93 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID', ]:
94 for x
in range(len(sys
.argv
)):
95 if string
.find(sys
.argv
[x
], flag
) == 0:
96 pos
= string
.find(sys
.argv
[x
], '=') + 1
98 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
101 for option
in ['WX_CONFIG', 'WXDLLVER', ]:
102 for x
in range(len(sys
.argv
)):
103 if string
.find(sys
.argv
[x
], option
) == 0:
104 pos
= string
.find(sys
.argv
[x
], '=') + 1
106 vars()[option
] = sys
.argv
[x
][pos
:]
109 sys
.argv
= filter(None, sys
.argv
)
117 #----------------------------------------------------------------------
118 # Setup some platform specific stuff
119 #----------------------------------------------------------------------
122 # Set compile flags and such for MSVC. These values are derived
123 # from the wxWindows makefiles for MSVC, others will probably
125 WXDIR
= os
.environ
['WXWIN']
137 os
.path
.join(WXDIR
, 'include'),
140 defines
= [ ('WIN32', None), # Some of these are no longer
141 ('__WIN32__', None), # necessary. Anybody know which?
143 ('__WINDOWS__', None),
144 ('WINVER', '0x0400'),
151 ('SWIG_GLOBAL', None),
152 ('HAVE_CONFIG_H', None),
153 ('WXP_USE_THREAD', '1'),
156 if bcpp_compiling
: # overwrite it
159 ('WINVER', '0x0400'),
164 ('SWIG_GLOBAL', None),
165 ('HAVE_CONFIG_H', None),
166 ('WXP_USE_THREAD', '1'),
168 ('WXUSE_DEFINE','1'),
173 if not FINAL
or HYBRID
:
174 defines
.append( ('__WXDEBUG__', None) )
176 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
179 wxdll
= 'wx' + WXDLLVER
181 wxdll
= 'wx' + WXDLLVER
+ 'h'
183 wxdll
= 'wx' + WXDLLVER
+ 'd'
188 libs
= ['wx'+WXBCPPLIBVER
]
190 libs
= libs
+ ['kernel32', 'user32', 'gdi32', 'comdlg32',
191 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
192 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
193 'advapi32', 'wsock32']
196 cflags
= [] #['/GX-'] # workaround for internal compiler error in MSVC 5
200 if bcpp_compiling
: # overwrite it
201 cflags
= ['-5', '-VF', ### To supplort MSVC spurious semicolons in the class scope
202 ### else, all semicolons at the end of all DECLARE_...CALLBACK... macros must be eliminated
203 '-Hc', '-H='+WXDIR
+'\src\msw\wx32.csm',
204 '@'+WXDIR
+'\src\msw\wxwin32.cfg'
208 if not FINAL
and HYBRID
and not bcpp_compiling
:
209 cflags
= cflags
+ ['/Od', '/Z7']
210 lflags
= ['/DEBUG', ]
212 elif bcpp_compiling
and not FINAL
:
213 cflags
= cflags
+ ['/Od', '/v', '/y']
214 lflags
= lflags
+ ['/v', ] ## '/PDB:NONE']
218 elif os
.name
== 'posix':
219 # Set flags for Unix type platforms
221 WXDIR
= '..' # assumes IN_CVS_TREE
222 WXPLAT
= '__WXGTK__' # and assumes GTK...
223 GENDIR
= 'gtk' # Need to allow for Motif eventually too
226 defines
= [('SWIG_GLOBAL', None),
227 ('HAVE_CONFIG_H', None),
228 ('WXP_USE_THREAD', '1'),
233 cflags
= os
.popen(WX_CONFIG
+ ' --cflags', 'r').read()[:-1] + ' ' + \
234 os
.popen('gtk-config --cflags', 'r').read()[:-1]
235 cflags
= string
.split(cflags
)
237 lflags
= os
.popen(WX_CONFIG
+ ' --libs', 'r').read()[:-1]
238 lflags
= string
.split(lflags
)
242 raise 'Sorry Charlie...'
245 #----------------------------------------------------------------------
246 # Check if the version file needs updated
247 #----------------------------------------------------------------------
249 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
250 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
254 #----------------------------------------------------------------------
256 #----------------------------------------------------------------------
259 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
260 '-I./src', '-D'+WXPLAT
]
261 swig_deps
= ['src/my_typemaps.i']
264 #----------------------------------------------------------------------
265 # Define the CORE extension module
266 #----------------------------------------------------------------------
269 print 'Preparing CORE...'
270 swig_files
= [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
271 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
272 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
273 'printfw.i', 'sizers.i', 'clip_dnd.i',
274 'filesys.i', 'streams.i',
275 ##'grid.i', 'html.i', 'htmlhelp.i', 'calendar.i', 'utils.i',
278 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
279 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
281 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
282 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
285 if IN_CVS_TREE
: # update the licence files
287 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
288 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
292 rc_file
= ['src/wxc.rc']
297 ext
= Extension('wxc', ['src/helpers.cpp',
299 ] + rc_file
+ swig_sources
,
301 include_dirs
= includes
,
302 define_macros
= defines
,
304 library_dirs
= libdirs
,
307 extra_compile_args
= cflags
,
308 extra_link_args
= lflags
,
310 wxpExtensions
.append(ext
)
313 # Extension for the grid module
314 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
315 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
316 ext
= Extension('gridc', swig_sources
,
317 include_dirs
= includes
,
318 define_macros
= defines
,
319 library_dirs
= libdirs
,
321 extra_compile_args
= cflags
,
322 extra_link_args
= lflags
,
324 wxpExtensions
.append(ext
)
327 # Extension for the html modules
328 swig_sources
= run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR
, PKGDIR
,
329 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
330 ext
= Extension('htmlc', swig_sources
,
331 include_dirs
= includes
,
332 define_macros
= defines
,
333 library_dirs
= libdirs
,
335 extra_compile_args
= cflags
,
336 extra_link_args
= lflags
,
338 wxpExtensions
.append(ext
)
341 # Extension for the utils module
342 swig_sources
= run_swig(['utils.i'], 'src', GENDIR
, PKGDIR
,
343 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
344 ext
= Extension('utilsc', swig_sources
,
345 include_dirs
= includes
,
346 define_macros
= defines
,
347 library_dirs
= libdirs
,
349 extra_compile_args
= cflags
,
350 extra_link_args
= lflags
,
352 wxpExtensions
.append(ext
)
355 # Extension for the calendar module
356 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
357 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
358 ext
= Extension('calendarc', swig_sources
,
359 include_dirs
= includes
,
360 define_macros
= defines
,
361 library_dirs
= libdirs
,
363 extra_compile_args
= cflags
,
364 extra_link_args
= lflags
,
366 wxpExtensions
.append(ext
)
369 #----------------------------------------------------------------------
370 # Define the GLCanvas extension module
371 #----------------------------------------------------------------------
373 if BUILD_GLCANVAS
or GL_ONLY
:
374 print 'Preparing GLCANVAS...'
375 location
= 'contrib/glcanvas'
376 swig_files
= ['glcanvas.i']
379 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
380 USE_SWIG
, swig_force
, swig_args
)
383 if os
.name
== 'posix':
384 if '-D__WXDEBUG__' in cflags
:
385 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
387 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
389 other_sources
= [location
+ '/msw/myglcanvas.cpp']
390 gl_libs
= ['opengl32', 'glu32']
393 ext
= Extension('glcanvasc',
394 swig_sources
+ other_sources
,
396 include_dirs
= includes
,
397 define_macros
= defines
,
399 library_dirs
= libdirs
,
400 libraries
= libs
+ gl_libs
,
402 extra_compile_args
= cflags
,
403 extra_link_args
= lflags
,
406 wxpExtensions
.append(ext
)
409 #----------------------------------------------------------------------
410 # Define the OGL extension module
411 #----------------------------------------------------------------------
413 if not GL_ONLY
and BUILD_OGL
:
414 print 'Preparing OGL...'
415 location
= 'contrib/ogl'
416 OGLLOC
= location
+ '/contrib/src/ogl'
417 OGLINC
= location
+ '/contrib/include'
419 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
422 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
423 USE_SWIG
, swig_force
, swig_args
)
425 # make sure local copy of contrib files are up to date
427 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
428 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
430 ext
= Extension('oglc', ['%s/basic.cpp' % OGLLOC
,
431 '%s/bmpshape.cpp' % OGLLOC
,
432 '%s/composit.cpp' % OGLLOC
,
433 '%s/divided.cpp' % OGLLOC
,
434 '%s/lines.cpp' % OGLLOC
,
435 '%s/misc.cpp' % OGLLOC
,
436 '%s/basic2.cpp' % OGLLOC
,
437 '%s/canvas.cpp' % OGLLOC
,
438 '%s/constrnt.cpp' % OGLLOC
,
439 '%s/drawn.cpp' % OGLLOC
,
440 '%s/mfutils.cpp' % OGLLOC
,
441 '%s/ogldiag.cpp' % OGLLOC
,
444 include_dirs
= [OGLINC
] + includes
,
445 define_macros
= defines
,
447 library_dirs
= libdirs
,
450 extra_compile_args
= cflags
,
451 extra_link_args
= lflags
,
454 wxpExtensions
.append(ext
)
458 #----------------------------------------------------------------------
459 # Define the STC extension module
460 #----------------------------------------------------------------------
462 if not GL_ONLY
and BUILD_STC
:
463 print 'Preparing STC...'
464 location
= 'contrib/stc'
465 STCLOC
= location
+ '/contrib/src/stc'
466 STCINC
= location
+ '/contrib/include'
467 STC_H
= location
+ '/contrib/include/wx/stc'
469 # make sure local copy of contrib files are up to date
471 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
472 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
475 swig_files
= ['stc_.i']
476 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
477 USE_SWIG
, swig_force
,
478 swig_args
+ ['-I'+STC_H
, '-I'+location
],
481 # copy a project specific py module to the main package dir
482 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
484 # add some include dirs to the standard set
485 stc_includes
= includes
[:]
486 stc_includes
.append('%s/scintilla/include' % STCLOC
)
487 stc_includes
.append('%s/scintilla/src' % STCLOC
)
488 stc_includes
.append(STCINC
)
490 # and some macro definitions
491 stc_defines
= defines
[:]
492 stc_defines
.append( ('__WX__', None) )
493 stc_defines
.append( ('SCI_LEXER', None) )
496 ext
= Extension('stc_c',
497 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
498 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
499 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
500 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
501 '%s/scintilla/src/Document.cxx' % STCLOC
,
502 '%s/scintilla/src/Editor.cxx' % STCLOC
,
503 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
504 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
505 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
506 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
507 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
508 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
509 '%s/scintilla/src/Style.cxx' % STCLOC
,
510 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
511 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
512 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
513 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
514 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
515 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
516 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
517 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
518 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
519 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
520 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
521 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
522 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
524 '%s/PlatWX.cpp' % STCLOC
,
525 '%s/ScintillaWX.cpp' % STCLOC
,
526 '%s/stc.cpp' % STCLOC
,
529 include_dirs
= stc_includes
,
530 define_macros
= stc_defines
,
532 library_dirs
= libdirs
,
535 extra_compile_args
= cflags
,
536 extra_link_args
= lflags
,
539 wxpExtensions
.append(ext
)
543 #----------------------------------------------------------------------
544 # Define the IEWIN extension module (experimental)
545 #----------------------------------------------------------------------
547 if not GL_ONLY
and BUILD_IEWIN
:
548 print 'Preparing IEWIN...'
549 location
= 'contrib/iewin'
551 swig_files
= ['iewin.i', ]
553 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
554 USE_SWIG
, swig_force
, swig_args
)
557 ext
= Extension('iewinc', ['%s/IEHtmlWin.cpp' % location
,
560 include_dirs
= includes
,
561 define_macros
= defines
,
563 library_dirs
= libdirs
,
566 extra_compile_args
= cflags
,
567 extra_link_args
= lflags
,
570 wxpExtensions
.append(ext
)
574 #----------------------------------------------------------------------
575 # Do the Setup/Build/Install/Whatever
576 #----------------------------------------------------------------------
578 if __name__
== "__main__":
582 description
= DESCRIPTION
,
583 long_description
= LONG_DESCRIPTION
,
585 author_email
= AUTHOR_EMAIL
,
591 PKGDIR
+'.lib.editor',
594 ext_package
= PKGDIR
,
595 ext_modules
= wxpExtensions
,
600 setup(name
= "wxPython-gl",
602 description
= "wxGLCanvas class for wxPython",
604 author_email
= AUTHOR_EMAIL
,
608 py_modules
= [ "wxPython.glcanvas" ],
610 ext_package
= PKGDIR
,
611 ext_modules
= wxpExtensions
,
617 #----------------------------------------------------------------------
618 #----------------------------------------------------------------------