]>
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)
35 BUILD_XRC
= 1 # XML based resource system
38 CORE_ONLY
= 0 # if true, don't build any of the above
39 GL_ONLY
= 0 # Only used when making the -gl RPM. See the "b" script
40 # for the ugly details
42 USE_SWIG
= 0 # Should we actually execute SWIG, or just use the
43 # files already in the distribution?
45 IN_CVS_TREE
= 0 # Set to true if building in a full wxWindows CVS
46 # tree, otherwise will assume all needed files are
47 # available in the wxPython source distribution
49 WX_CONFIG
= "wx-config" # Usually you shouldn't need to touch this,
50 # but you can set it to pass an alternate
51 # version of wx-config or alternate flags,
52 # eg. as required by the .deb in-tree build.
54 # Some MSW build settings
56 FINAL
= 1 # Mirrors use of same flag in wx makefiles,
57 # (0 or 1 only) should probably find a way to
60 HYBRID
= 0 # If set and not debug or FINAL, then build a
61 # hybrid extension that can be used by the
62 # non-debug version of python, but contains
63 # debugging symbols for wxWindows and wxPython.
64 # wxWindows must have been built with /MD, not /MDd
65 # (using FINAL=hybrid will do it.)
67 WXDLLVER
= '23_1' # Version part of DLL name
70 #----------------------------------------------------------------------
72 #----------------------------------------------------------------------
77 force
= '--force' in sys
.argv
or '-f' in sys
.argv
78 debug
= '--debug' in sys
.argv
or '-g' in sys
.argv
80 bcpp_compiling
= '-c' in sys
.argv
and 'my_bcpp' in sys
.argv
# Bad heuristic
83 print "Compiling wxPython by Borland C/C++ Compiler"
85 WXBCPPLIBVER
= string
.replace(WXDLLVER
,"_","")
86 # Version part of BCPP build LIBRARY name
87 WXDLLVER
="" # no dll ver path avaible
90 #----------------------------------------------------------------------
91 # Check for build flags on the command line
92 #----------------------------------------------------------------------
94 for flag
in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'CORE_ONLY',
95 'USE_SWIG', 'IN_CVS_TREE', 'FINAL', 'HYBRID', ]:
96 for x
in range(len(sys
.argv
)):
97 if string
.find(sys
.argv
[x
], flag
) == 0:
98 pos
= string
.find(sys
.argv
[x
], '=') + 1
100 vars()[flag
] = eval(sys
.argv
[x
][pos
:])
103 for option
in ['WX_CONFIG', 'WXDLLVER', ]:
104 for x
in range(len(sys
.argv
)):
105 if string
.find(sys
.argv
[x
], option
) == 0:
106 pos
= string
.find(sys
.argv
[x
], '=') + 1
108 vars()[option
] = sys
.argv
[x
][pos
:]
111 sys
.argv
= filter(None, sys
.argv
)
119 #----------------------------------------------------------------------
120 # Setup some platform specific stuff
121 #----------------------------------------------------------------------
124 # Set compile flags and such for MSVC. These values are derived
125 # from the wxWindows makefiles for MSVC, others will probably
127 WXDIR
= os
.environ
['WXWIN']
139 os
.path
.join(WXDIR
, 'include'),
142 defines
= [ ('WIN32', None), # Some of these are no longer
143 ('__WIN32__', None), # necessary. Anybody know which?
145 ('__WINDOWS__', None),
146 ('WINVER', '0x0400'),
153 ('SWIG_GLOBAL', None),
154 ('HAVE_CONFIG_H', None),
155 ('WXP_USE_THREAD', '1'),
158 if bcpp_compiling
: # overwrite it
161 ('WINVER', '0x0400'),
166 ('SWIG_GLOBAL', None),
167 ('HAVE_CONFIG_H', None),
168 ('WXP_USE_THREAD', '1'),
170 ('WXUSE_DEFINE','1'),
175 if not FINAL
or HYBRID
:
176 defines
.append( ('__WXDEBUG__', None) )
178 libdirs
= [os
.path
.join(WXDIR
, 'lib'), 'build\\ilib']
181 wxdll
= 'wx' + WXDLLVER
183 wxdll
= 'wx' + WXDLLVER
+ 'h'
185 wxdll
= 'wx' + WXDLLVER
+ 'd'
190 libs
= ['wx'+WXBCPPLIBVER
]
192 libs
= libs
+ ['kernel32', 'user32', 'gdi32', 'comdlg32',
193 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32',
194 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4',
195 'advapi32', 'wsock32']
198 cflags
= [] #['/GX-'] # workaround for internal compiler error in MSVC 5
202 if bcpp_compiling
: # overwrite it
203 cflags
= ['-5', '-VF', ### To supplort MSVC spurious semicolons in the class scope
204 ### else, all semicolons at the end of all DECLARE_...CALLBACK... macros must be eliminated
205 '-Hc', '-H='+WXDIR
+'\src\msw\wx32.csm',
206 '@'+WXDIR
+'\src\msw\wxwin32.cfg'
210 if not FINAL
and HYBRID
and not bcpp_compiling
:
211 cflags
= cflags
+ ['/Od', '/Z7']
212 lflags
= ['/DEBUG', ]
214 elif bcpp_compiling
and not FINAL
:
215 cflags
= cflags
+ ['/Od', '/v', '/y']
216 lflags
= lflags
+ ['/v', ] ## '/PDB:NONE']
220 elif os
.name
== 'posix':
221 # Set flags for Unix type platforms
223 WXDIR
= '..' # assumes IN_CVS_TREE
224 WXPLAT
= '__WXGTK__' # and assumes GTK...
225 GENDIR
= 'gtk' # Need to allow for Motif eventually too
228 defines
= [('SWIG_GLOBAL', None),
229 ('HAVE_CONFIG_H', None),
230 ('WXP_USE_THREAD', '1'),
235 cflags
= os
.popen(WX_CONFIG
+ ' --cflags', 'r').read()[:-1] + ' ' + \
236 os
.popen('gtk-config --cflags', 'r').read()[:-1]
237 cflags
= string
.split(cflags
)
239 lflags
= os
.popen(WX_CONFIG
+ ' --libs', 'r').read()[:-1]
240 lflags
= string
.split(lflags
)
244 raise 'Sorry Charlie...'
247 #----------------------------------------------------------------------
248 # Check if the version file needs updated
249 #----------------------------------------------------------------------
251 if IN_CVS_TREE
and newer('setup.py', 'src/__version__.py'):
252 open('src/__version__.py', 'w').write("ver = '%s'\n" % VERSION
)
256 #----------------------------------------------------------------------
258 #----------------------------------------------------------------------
261 swig_args
= ['-c++', '-shadow', '-python', '-keyword', '-dnone', #'-dascii',
262 '-I./src', '-D'+WXPLAT
]
263 swig_deps
= ['src/my_typemaps.i']
266 #----------------------------------------------------------------------
267 # Define the CORE extension module
268 #----------------------------------------------------------------------
271 print 'Preparing CORE...'
272 swig_files
= [ 'wx.i', 'windows.i', 'windows2.i', 'windows3.i', 'events.i',
273 'misc.i', 'misc2.i', 'gdi.i', 'mdi.i', 'controls.i',
274 'controls2.i', 'cmndlgs.i', 'stattool.i', 'frames.i', 'image.i',
275 'printfw.i', 'sizers.i', 'clip_dnd.i',
276 'filesys.i', 'streams.i',
277 ##'grid.i', 'html.i', 'htmlhelp.i', 'calendar.i', 'utils.i',
280 swig_sources
= run_swig(swig_files
, 'src', GENDIR
, PKGDIR
,
281 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
283 copy_file('src/__init__.py', PKGDIR
, update
=1, verbose
=0)
284 copy_file('src/__version__.py', PKGDIR
, update
=1, verbose
=0)
287 if IN_CVS_TREE
: # update the licence files
289 for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
290 copy_file(WXDIR
+'/docs/'+file, 'licence/'+file, update
=1, verbose
=0)
294 rc_file
= ['src/wxc.rc']
299 ext
= Extension('wxc', ['src/helpers.cpp',
301 ] + rc_file
+ swig_sources
,
303 include_dirs
= includes
,
304 define_macros
= defines
,
306 library_dirs
= libdirs
,
309 extra_compile_args
= cflags
,
310 extra_link_args
= lflags
,
312 wxpExtensions
.append(ext
)
315 # Extension for the grid module
316 swig_sources
= run_swig(['grid.i'], 'src', GENDIR
, PKGDIR
,
317 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
318 ext
= Extension('gridc', swig_sources
,
319 include_dirs
= includes
,
320 define_macros
= defines
,
321 library_dirs
= libdirs
,
323 extra_compile_args
= cflags
,
324 extra_link_args
= lflags
,
326 wxpExtensions
.append(ext
)
329 # Extension for the html modules
330 swig_sources
= run_swig(['html.i', 'htmlhelp.i'], 'src', GENDIR
, PKGDIR
,
331 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
332 ext
= Extension('htmlc', swig_sources
,
333 include_dirs
= includes
,
334 define_macros
= defines
,
335 library_dirs
= libdirs
,
337 extra_compile_args
= cflags
,
338 extra_link_args
= lflags
,
340 wxpExtensions
.append(ext
)
343 # Extension for the utils module
344 swig_sources
= run_swig(['utils.i'], 'src', GENDIR
, PKGDIR
,
345 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
346 ext
= Extension('utilsc', swig_sources
,
347 include_dirs
= includes
,
348 define_macros
= defines
,
349 library_dirs
= libdirs
,
351 extra_compile_args
= cflags
,
352 extra_link_args
= lflags
,
354 wxpExtensions
.append(ext
)
357 # Extension for the calendar module
358 swig_sources
= run_swig(['calendar.i'], 'src', GENDIR
, PKGDIR
,
359 USE_SWIG
, swig_force
, swig_args
, swig_deps
)
360 ext
= Extension('calendarc', swig_sources
,
361 include_dirs
= includes
,
362 define_macros
= defines
,
363 library_dirs
= libdirs
,
365 extra_compile_args
= cflags
,
366 extra_link_args
= lflags
,
368 wxpExtensions
.append(ext
)
371 #----------------------------------------------------------------------
372 # Define the GLCanvas extension module
373 #----------------------------------------------------------------------
375 if BUILD_GLCANVAS
or GL_ONLY
:
376 print 'Preparing GLCANVAS...'
377 location
= 'contrib/glcanvas'
378 swig_files
= ['glcanvas.i']
381 swig_sources
= run_swig(swig_files
, location
, GENDIR
, PKGDIR
,
382 USE_SWIG
, swig_force
, swig_args
)
385 if os
.name
== 'posix':
386 if '-D__WXDEBUG__' in cflags
:
387 gl_libs
= ['wx_gtkd_gl', 'GL', 'GLU']
389 gl_libs
= ['wx_gtk_gl', 'GL', 'GLU']
391 other_sources
= [location
+ '/msw/myglcanvas.cpp']
392 gl_libs
= ['opengl32', 'glu32']
395 ext
= Extension('glcanvasc',
396 swig_sources
+ other_sources
,
398 include_dirs
= includes
,
399 define_macros
= defines
,
401 library_dirs
= libdirs
,
402 libraries
= libs
+ gl_libs
,
404 extra_compile_args
= cflags
,
405 extra_link_args
= lflags
,
408 wxpExtensions
.append(ext
)
411 #----------------------------------------------------------------------
412 # Define the OGL extension module
413 #----------------------------------------------------------------------
415 if not GL_ONLY
and BUILD_OGL
:
416 print 'Preparing OGL...'
417 location
= 'contrib/ogl'
418 OGLLOC
= location
+ '/contrib/src/ogl'
419 OGLINC
= location
+ '/contrib/include'
421 swig_files
= ['ogl.i', 'oglbasic.i', 'oglshapes.i', 'oglshapes2.i',
424 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
425 USE_SWIG
, swig_force
, swig_args
)
427 # make sure local copy of contrib files are up to date
429 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/ogl', OGLINC
+'/wx/ogl')
430 contrib_copy_tree(WXDIR
+ '/contrib/src/ogl', OGLLOC
)
432 ext
= Extension('oglc', ['%s/basic.cpp' % OGLLOC
,
433 '%s/bmpshape.cpp' % OGLLOC
,
434 '%s/composit.cpp' % OGLLOC
,
435 '%s/divided.cpp' % OGLLOC
,
436 '%s/lines.cpp' % OGLLOC
,
437 '%s/misc.cpp' % OGLLOC
,
438 '%s/basic2.cpp' % OGLLOC
,
439 '%s/canvas.cpp' % OGLLOC
,
440 '%s/constrnt.cpp' % OGLLOC
,
441 '%s/drawn.cpp' % OGLLOC
,
442 '%s/mfutils.cpp' % OGLLOC
,
443 '%s/ogldiag.cpp' % OGLLOC
,
446 include_dirs
= [OGLINC
] + includes
,
447 define_macros
= defines
,
449 library_dirs
= libdirs
,
452 extra_compile_args
= cflags
,
453 extra_link_args
= lflags
,
456 wxpExtensions
.append(ext
)
460 #----------------------------------------------------------------------
461 # Define the STC extension module
462 #----------------------------------------------------------------------
464 if not GL_ONLY
and BUILD_STC
:
465 print 'Preparing STC...'
466 location
= 'contrib/stc'
467 STCLOC
= location
+ '/contrib/src/stc'
468 STCINC
= location
+ '/contrib/include'
469 STC_H
= location
+ '/contrib/include/wx/stc'
471 # make sure local copy of contrib files are up to date
473 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/stc', STCINC
+'/wx/stc')
474 contrib_copy_tree(WXDIR
+ '/contrib/src/stc', STCLOC
)
477 swig_files
= ['stc_.i']
478 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
479 USE_SWIG
, swig_force
,
480 swig_args
+ ['-I'+STC_H
, '-I'+location
],
483 # copy a project specific py module to the main package dir
484 copy_file(location
+'/stc.py', PKGDIR
, update
=1, verbose
=1)
486 # add some include dirs to the standard set
487 stc_includes
= includes
[:]
488 stc_includes
.append('%s/scintilla/include' % STCLOC
)
489 stc_includes
.append('%s/scintilla/src' % STCLOC
)
490 stc_includes
.append(STCINC
)
492 # and some macro definitions
493 stc_defines
= defines
[:]
494 stc_defines
.append( ('__WX__', None) )
495 stc_defines
.append( ('SCI_LEXER', None) )
498 ext
= Extension('stc_c',
499 ['%s/scintilla/src/AutoComplete.cxx' % STCLOC
,
500 '%s/scintilla/src/CallTip.cxx' % STCLOC
,
501 '%s/scintilla/src/CellBuffer.cxx' % STCLOC
,
502 '%s/scintilla/src/ContractionState.cxx' % STCLOC
,
503 '%s/scintilla/src/Document.cxx' % STCLOC
,
504 '%s/scintilla/src/Editor.cxx' % STCLOC
,
505 '%s/scintilla/src/Indicator.cxx' % STCLOC
,
506 '%s/scintilla/src/KeyMap.cxx' % STCLOC
,
507 '%s/scintilla/src/KeyWords.cxx' % STCLOC
,
508 '%s/scintilla/src/LineMarker.cxx' % STCLOC
,
509 '%s/scintilla/src/PropSet.cxx' % STCLOC
,
510 '%s/scintilla/src/ScintillaBase.cxx' % STCLOC
,
511 '%s/scintilla/src/Style.cxx' % STCLOC
,
512 '%s/scintilla/src/ViewStyle.cxx' % STCLOC
,
513 '%s/scintilla/src/LexCPP.cxx' % STCLOC
,
514 '%s/scintilla/src/LexHTML.cxx' % STCLOC
,
515 '%s/scintilla/src/LexLua.cxx' % STCLOC
,
516 '%s/scintilla/src/LexOthers.cxx' % STCLOC
,
517 '%s/scintilla/src/LexPerl.cxx' % STCLOC
,
518 '%s/scintilla/src/LexPython.cxx' % STCLOC
,
519 '%s/scintilla/src/LexSQL.cxx' % STCLOC
,
520 '%s/scintilla/src/LexVB.cxx' % STCLOC
,
521 '%s/scintilla/src/DocumentAccessor.cxx' % STCLOC
,
522 '%s/scintilla/src/UniConversion.cxx' % STCLOC
,
523 '%s/scintilla/src/WindowAccessor.cxx' % STCLOC
,
524 '%s/scintilla/src/PosRegExp.cxx' % STCLOC
,
526 '%s/PlatWX.cpp' % STCLOC
,
527 '%s/ScintillaWX.cpp' % STCLOC
,
528 '%s/stc.cpp' % STCLOC
,
531 include_dirs
= stc_includes
,
532 define_macros
= stc_defines
,
534 library_dirs
= libdirs
,
537 extra_compile_args
= cflags
,
538 extra_link_args
= lflags
,
541 wxpExtensions
.append(ext
)
545 #----------------------------------------------------------------------
546 # Define the IEWIN extension module (experimental)
547 #----------------------------------------------------------------------
549 if not GL_ONLY
and BUILD_IEWIN
:
550 print 'Preparing IEWIN...'
551 location
= 'contrib/iewin'
553 swig_files
= ['iewin.i', ]
555 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
556 USE_SWIG
, swig_force
, swig_args
)
559 ext
= Extension('iewinc', ['%s/IEHtmlWin.cpp' % location
,
562 include_dirs
= includes
,
563 define_macros
= defines
,
565 library_dirs
= libdirs
,
568 extra_compile_args
= cflags
,
569 extra_link_args
= lflags
,
572 wxpExtensions
.append(ext
)
575 #----------------------------------------------------------------------
576 # Define the XRC extension module
577 #----------------------------------------------------------------------
579 if not GL_ONLY
and BUILD_XRC
:
580 print 'Preparing XRC...'
581 location
= 'contrib/xrc'
582 XMLLOC
= location
+ '/contrib/src/xrc'
583 XMLINC
= location
+ '/contrib/include'
585 swig_files
= ['xrc.i']
587 swig_sources
= run_swig(swig_files
, location
, '', PKGDIR
,
588 USE_SWIG
, swig_force
, swig_args
)
590 xmlres_includes
= includes
[:]
591 xmlres_includes
.append('%s/expat/xmlparse' % XMLLOC
)
592 xmlres_includes
.append('%s/expat/xmltok' % XMLLOC
)
593 xmlres_includes
.append(XMLINC
)
596 # make sure local copy of contrib files are up to date
598 contrib_copy_tree(WXDIR
+ '/contrib/include/wx/xrc', XMLINC
+'/wx/xrc')
599 contrib_copy_tree(WXDIR
+ '/contrib/src/xrc', XMLLOC
)
601 ext
= Extension('xrcc', ['%s/expat/xmlparse/xmlparse.c' % XMLLOC
,
602 '%s/expat/xmltok/xmlrole.c' % XMLLOC
,
603 '%s/expat/xmltok/xmltok.c' % XMLLOC
,
605 '%s/xh_bmp.cpp' % XMLLOC
,
606 '%s/xh_bmpbt.cpp' % XMLLOC
,
607 '%s/xh_bttn.cpp' % XMLLOC
,
608 '%s/xh_cald.cpp' % XMLLOC
,
609 '%s/xh_chckb.cpp' % XMLLOC
,
611 '%s/xh_chckl.cpp' % XMLLOC
,
612 '%s/xh_choic.cpp' % XMLLOC
,
613 '%s/xh_combo.cpp' % XMLLOC
,
614 '%s/xh_dlg.cpp' % XMLLOC
,
615 '%s/xh_frame.cpp' % XMLLOC
,
617 '%s/xh_gauge.cpp' % XMLLOC
,
618 '%s/xh_html.cpp' % XMLLOC
,
619 '%s/xh_listb.cpp' % XMLLOC
,
620 '%s/xh_listc.cpp' % XMLLOC
,
621 '%s/xh_menu.cpp' % XMLLOC
,
623 '%s/xh_notbk.cpp' % XMLLOC
,
624 '%s/xh_panel.cpp' % XMLLOC
,
625 '%s/xh_radbt.cpp' % XMLLOC
,
626 '%s/xh_radbx.cpp' % XMLLOC
,
627 '%s/xh_scrol.cpp' % XMLLOC
,
629 '%s/xh_sizer.cpp' % XMLLOC
,
630 '%s/xh_slidr.cpp' % XMLLOC
,
631 '%s/xh_spin.cpp' % XMLLOC
,
632 '%s/xh_stbmp.cpp' % XMLLOC
,
633 '%s/xh_stbox.cpp' % XMLLOC
,
635 '%s/xh_stlin.cpp' % XMLLOC
,
636 '%s/xh_sttxt.cpp' % XMLLOC
,
637 '%s/xh_text.cpp' % XMLLOC
,
638 '%s/xh_toolb.cpp' % XMLLOC
,
639 '%s/xh_tree.cpp' % XMLLOC
,
641 '%s/xh_unkwn.cpp' % XMLLOC
,
642 '%s/xml.cpp' % XMLLOC
,
643 '%s/xmlbin.cpp' % XMLLOC
,
644 '%s/xmlbinz.cpp' % XMLLOC
,
645 '%s/xmlexpat.cpp' % XMLLOC
,
647 '%s/xmlres.cpp' % XMLLOC
,
648 '%s/xmlrsall.cpp' % XMLLOC
,
649 '%s/xmlwrite.cpp' % XMLLOC
,
653 include_dirs
= xmlres_includes
,
654 define_macros
= defines
,
656 library_dirs
= libdirs
,
659 extra_compile_args
= cflags
,
660 extra_link_args
= lflags
,
663 wxpExtensions
.append(ext
)
668 #----------------------------------------------------------------------
669 # Do the Setup/Build/Install/Whatever
670 #----------------------------------------------------------------------
672 if __name__
== "__main__":
676 description
= DESCRIPTION
,
677 long_description
= LONG_DESCRIPTION
,
679 author_email
= AUTHOR_EMAIL
,
685 PKGDIR
+'.lib.editor',
688 ext_package
= PKGDIR
,
689 ext_modules
= wxpExtensions
,
694 setup(name
= "wxPython-gl",
696 description
= "wxGLCanvas class for wxPython",
698 author_email
= AUTHOR_EMAIL
,
702 py_modules
= [ "wxPython.glcanvas" ],
704 ext_package
= PKGDIR
,
705 ext_modules
= wxpExtensions
,
711 #----------------------------------------------------------------------
712 #----------------------------------------------------------------------