]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/setup.py
Log the exception when writing to file fails.
[wxWidgets.git] / wxPython / setup.py
index 77e7d5aa37460b51db10d01bd06d68ac3d89ef3d..76b3aa4557de16a4dbccfb6eb12827293753af2f 100755 (executable)
@@ -11,7 +11,7 @@
 # Licence:     wxWindows license
 #----------------------------------------------------------------------
 
-import sys
+import sys, os
 
 
 # The full contents of the wx.build.config module used to be located
@@ -29,6 +29,14 @@ import sys
 # config .py in the same place as setup.py, and then copy it to
 # wx/build as needed below.
 
+# To fully support external builds, we need to have a build options
+# file that is created whenever a new wxPython build is performed.
+# We happen to be doing that in this script, so make sure to remove
+# the build_options.py file, so that config.py will recreate it.
+
+if os.path.exists("build_options.py"):
+    os.remove("build_options.py")
+
 sys.setup_is_main =  __name__ == "__main__"  # an icky hack!
 from config import *
 
@@ -38,7 +46,9 @@ from config import *
 #----------------------------------------------------------------------
 
 copy_file('config.py', 'wx/build', update=1, verbose=1)
+copy_file('build_options.py', 'wx/build', update=1, verbose=1)
 CLEANUP.append('wx/build/config.py')
+CLEANUP.append('wx/build/build_options.py')
 
 #----------------------------------------------------------------------
 # Update the version file
@@ -65,6 +75,20 @@ RELEASE_NUMBER = RELEASE_VERSION  # for compatibility
 CLEANUP.append('wx/__version__.py')
 
 
+#----------------------------------------------------------------------
+# patch distutils if it can't cope with the "classifiers" or
+# "download_url" keywords 
+#----------------------------------------------------------------------
+
+if sys.version < '2.2.3': 
+    from distutils.dist import DistributionMetadata 
+    DistributionMetadata.classifiers = None 
+    DistributionMetadata.download_url = None
+    depends = {}
+else:
+    depends = {'depends' : depends}
+    
+
 #----------------------------------------------------------------------
 # Define the CORE extension module
 #----------------------------------------------------------------------
@@ -78,11 +102,12 @@ swig_sources = run_swig(['core.i'], 'src', GENDIR, PKGDIR,
                           'src/_constraints.i',
                           'src/_core_api.i',
                           'src/_core_ex.py',
-                          'src/_core_rename.i',
-                          'src/_core_reverse.txt',
+                          'src/__core_rename.i',
+                          'src/__core_reverse.txt',
                           'src/_defs.i',
                           'src/_event.i',
                           'src/_event_ex.py',
+                          'src/_evtloop.i',
                           'src/_evthandler.i',
                           'src/_filesys.i',
                           'src/_gdicmn.i',
@@ -95,7 +120,8 @@ swig_sources = run_swig(['core.i'], 'src', GENDIR, PKGDIR,
                           'src/_validator.i',
                           'src/_window.i',
                           'src/_control.i',
-                          ])
+                          ],
+                        True)
 
 copy_file('src/__init__.py', PKGDIR, update=1, verbose=0)
 CLEANUP.append(opj(PKGDIR, '__init__.py'))
@@ -120,9 +146,8 @@ else:
     rc_file = []
 
 
-ext = Extension('_core', ['src/helpers.cpp',
-                          'src/libpy.c',
-                        ] + rc_file + swig_sources,
+ext = Extension('_core_', ['src/helpers.cpp',
+                           ] + rc_file + swig_sources,
 
                 include_dirs = includes,
                 define_macros = defines,
@@ -133,7 +158,7 @@ ext = Extension('_core', ['src/helpers.cpp',
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
 
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -144,7 +169,7 @@ wxpExtensions.append(ext)
 # Extension for the GDI module
 swig_sources = run_swig(['gdi.i'], 'src', GENDIR, PKGDIR,
                         USE_SWIG, swig_force, swig_args, swig_deps +
-                        ['src/_gdi_rename.i',
+                        ['src/__gdi_rename.i',
                          'src/_bitmap.i',
                          'src/_colour.i',
                          'src/_dc.i',
@@ -161,15 +186,17 @@ swig_sources = run_swig(['gdi.i'], 'src', GENDIR, PKGDIR,
                          'src/_icon.i',
                          'src/_pen.i',
                          'src/_palette.i',
-                         ])
-ext = Extension('_gdi', ['src/drawlist.cpp'] + swig_sources,
+                         'src/_renderer.i',
+                         ],
+                        True)
+ext = Extension('_gdi_', ['src/drawlist.cpp'] + swig_sources,
                 include_dirs =  includes,
                 define_macros = defines,
                 library_dirs = libdirs,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -181,8 +208,8 @@ wxpExtensions.append(ext)
 # Extension for the windows module
 swig_sources = run_swig(['windows.i'], 'src', GENDIR, PKGDIR,
                         USE_SWIG, swig_force, swig_args, swig_deps +
-                        ['src/_windows_rename.i',
-                         'src/_windows_reverse.txt',
+                        ['src/__windows_rename.i',
+                         'src/__windows_reverse.txt',
                          'src/_panel.i',
                          'src/_toplvl.i',
                          'src/_statusbar.i',
@@ -196,15 +223,16 @@ swig_sources = run_swig(['windows.i'], 'src', GENDIR, PKGDIR,
                          'src/_mdi.i',
                          'src/_pywindows.i',
                          'src/_printfw.i',
-                         ])
-ext = Extension('_windows', swig_sources,
+                         ],
+                        True)
+ext = Extension('_windows_', swig_sources,
                 include_dirs =  includes,
                 define_macros = defines,
                 library_dirs = libdirs,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -214,8 +242,8 @@ wxpExtensions.append(ext)
 # Extension for the controls module
 swig_sources = run_swig(['controls.i'], 'src', GENDIR, PKGDIR,
                         USE_SWIG, swig_force, swig_args, swig_deps +
-                        [ 'src/_controls_rename.i',
-                          'src/_controls_reverse.txt',
+                        [ 'src/__controls_rename.i',
+                          'src/__controls_reverse.txt',
                           'src/_toolbar.i',
                           'src/_button.i',
                           'src/_checkbox.i',
@@ -237,15 +265,17 @@ swig_sources = run_swig(['controls.i'], 'src', GENDIR, PKGDIR,
                           'src/_pycontrol.i',
                           'src/_cshelp.i',
                           'src/_dragimg.i',
-                          ])
-ext = Extension('_controls', swig_sources,
+                          'src/_datectrl.i',
+                          ],
+                        True)
+ext = Extension('_controls_', swig_sources,
                 include_dirs =  includes,
                 define_macros = defines,
                 library_dirs = libdirs,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -255,7 +285,9 @@ wxpExtensions.append(ext)
 # Extension for the misc module
 swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR,
                         USE_SWIG, swig_force, swig_args, swig_deps +
-                        [ 'src/_settings.i',
+                        [ 'src/__misc_rename.i',
+                          'src/__misc_reverse.txt',
+                          'src/_settings.i',
                           'src/_functions.i',
                           'src/_misc.i',
                           'src/_tipdlg.i',
@@ -272,15 +304,17 @@ swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR,
                           'src/_dnd.i',
                           'src/_display.i',
                           'src/_clipbrd.i',
-                          ])
-ext = Extension('_misc', swig_sources,
+                          'src/_stdpaths.i',
+                          ],
+                        True)
+ext = Extension('_misc_', swig_sources,
                 include_dirs =  includes,
                 define_macros = defines,
                 library_dirs = libdirs,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -299,7 +333,7 @@ ext = Extension('_calendar', swig_sources,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -313,7 +347,7 @@ ext = Extension('_grid', swig_sources,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -328,7 +362,38 @@ ext = Extension('_html', swig_sources,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
+                )
+wxpExtensions.append(ext)
+
+
+mediaLibs = libs[:]
+if not MONOLITHIC and os.name == 'nt':
+    mediaLibs.append(makeLibName('media')[0])
+swig_sources = run_swig(['media.i'], 'src', GENDIR, PKGDIR,
+                        USE_SWIG, swig_force, swig_args, swig_deps)
+ext = Extension('_media', swig_sources,
+                include_dirs =  includes,
+                define_macros = defines,
+                library_dirs = libdirs,
+                libraries = mediaLibs,
+                extra_compile_args = cflags,
+                extra_link_args = lflags,
+                **depends
+                )
+wxpExtensions.append(ext)
+
+
+swig_sources = run_swig(['webkit.i'], 'src', GENDIR, PKGDIR,
+                        USE_SWIG, swig_force, swig_args, swig_deps)
+ext = Extension('_webkit', swig_sources,
+                include_dirs =  includes,
+                define_macros = defines,
+                library_dirs = libdirs,
+                libraries = libs,
+                extra_compile_args = cflags,
+                extra_link_args = lflags,
+                **depends
                 )
 wxpExtensions.append(ext)
 
@@ -343,7 +408,32 @@ ext = Extension('_wizard', swig_sources,
                 libraries = libs,
                 extra_compile_args = cflags,
                 extra_link_args = lflags,
-                depends = depends
+                **depends
+                )
+wxpExtensions.append(ext)
+
+
+
+swig_sources = run_swig(['xrc.i'], 'src', GENDIR, PKGDIR,
+                        USE_SWIG, swig_force, swig_args, swig_deps +
+                        [ 'src/_xrc_rename.i',
+                          'src/_xrc_ex.py',
+                          'src/_xmlres.i',
+                          'src/_xmlsub.i',
+                          'src/_xml.i',
+                          'src/_xmlhandler.i',
+                          ])
+ext = Extension('_xrc',
+                swig_sources,
+
+                include_dirs =  includes + CONTRIBS_INC,
+                define_macros = defines,
+
+                library_dirs = libdirs,
+                libraries = libs,
+
+                extra_compile_args = cflags,
+                extra_link_args = lflags,
                 )
 wxpExtensions.append(ext)
 
@@ -361,7 +451,7 @@ if BUILD_GLCANVAS:
 
     gl_libs = []
     if os.name == 'posix':
-        gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1]
+        gl_config = os.popen(WX_CONFIG + ' --libs gl', 'r').read()[:-1]
         gl_lflags = gl_config.split() + lflags
         gl_libs = libs
     else:
@@ -425,10 +515,10 @@ if BUILD_OGL:
 if BUILD_STC:
     msg('Preparing STC...')
     location = 'contrib/stc'
-    if os.name == 'nt':
-        STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
-    else:
-        STC_H = opj(WXPREFIX, 'include/wx/stc')
+    #if os.name == 'nt':
+    STC_H = opj(WXDIR, 'contrib', 'include/wx/stc')
+    #else:
+    #    STC_H = opj(WXPREFIX, 'include/wx-%d.%d/wx/stc' % (VER_MAJOR, VER_MINOR))
 
 ## NOTE: need to add something like this to the stc.bkl...
 
@@ -446,10 +536,14 @@ if BUILD_STC:
 ##             os.chdir(cwd)
 
 
-    swig_sources = run_swig(['stc.i'], location, '', PKGDIR,
+    swig_sources = run_swig(['stc.i'], location, GENDIR, PKGDIR,
                             USE_SWIG, swig_force,
                             swig_args + ['-I'+STC_H, '-I'+location],
-                            [opj(STC_H, 'stc.h')] + swig_deps)
+                            [opj(STC_H, 'stc.h'),
+                             opj(location, "_stc_utf8_methods.py"),
+                             opj(location, "_stc_docstrings.i"),
+                             opj(location, "_stc_gendocs.i"),
+                             ] + swig_deps)
 
     ext = Extension('_stc',
                     swig_sources,
@@ -533,31 +627,24 @@ if BUILD_ACTIVEX:
 
 
 #----------------------------------------------------------------------
-# Define the XRC extension module
+# Define the GIZMOS  extension module
 #----------------------------------------------------------------------
 
-if BUILD_XRC:
-    msg('Preparing XRC...')
-    location = 'contrib/xrc'
+if BUILD_GIZMOS:
+    msg('Preparing GIZMOS...')
+    location = 'contrib/gizmos'
 
-    swig_sources = run_swig(['xrc.i'], location, '', PKGDIR,
-                            USE_SWIG, swig_force, swig_args, swig_deps +
-                            [ '%s/_xrc_rename.i' % location,
-                              '%s/_xrc_ex.py' % location,
-                              '%s/_xmlres.i' % location,
-                              '%s/_xmlsub.i' % location,
-                              '%s/_xml.i' % location,
-                              '%s/_xmlhandler.i' % location,
-                              ])
+    swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR,
+                            USE_SWIG, swig_force, swig_args, swig_deps)
 
-    ext = Extension('_xrc',
-                    swig_sources,
+    ext = Extension('_gizmos',
+                    [ '%s/treelistctrl.cpp' % opj(location, 'wxCode/src') ] + swig_sources,
 
-                    include_dirs =  includes + CONTRIBS_INC,
+                    include_dirs =  includes + [ location, opj(location, 'wxCode/include') ] + CONTRIBS_INC,
                     define_macros = defines,
 
                     library_dirs = libdirs,
-                    libraries = libs + makeLibName('xrc'),
+                    libraries = libs + makeLibName('gizmos'),
 
                     extra_compile_args = cflags,
                     extra_link_args = lflags,
@@ -566,26 +653,25 @@ if BUILD_XRC:
     wxpExtensions.append(ext)
 
 
-
 #----------------------------------------------------------------------
-# Define the GIZMOS  extension module
+# Define the ANIMATE  extension module
 #----------------------------------------------------------------------
 
-if BUILD_GIZMOS:
-    msg('Preparing GIZMOS...')
-    location = 'contrib/gizmos'
+if BUILD_ANIMATE:
+    msg('Preparing ANIMATE...')
+    location = 'contrib/animate'
 
-    swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR,
+    swig_sources = run_swig(['animate.i'], location, GENDIR, PKGDIR,
                             USE_SWIG, swig_force, swig_args, swig_deps)
 
-    ext = Extension('_gizmos',
-                    [ '%s/treelistctrl.cpp' % location ] + swig_sources,
+    ext = Extension('_animate',
+                    swig_sources,
 
-                    include_dirs =  includes + [ location ] + CONTRIBS_INC,
+                    include_dirs =  includes + CONTRIBS_INC,
                     define_macros = defines,
 
                     library_dirs = libdirs,
-                    libraries = libs + makeLibName('gizmos'),
+                    libraries = libs + makeLibName('animate'),
 
                     extra_compile_args = cflags,
                     extra_link_args = lflags,
@@ -629,7 +715,7 @@ if BUILD_DLLWIDGET:
 
 
 
-
+    
 #----------------------------------------------------------------------
 # Tools, scripts data files, etc.
 #----------------------------------------------------------------------
@@ -639,18 +725,20 @@ if NO_SCRIPTS:
 else:
     SCRIPTS = [opj('scripts/helpviewer'),
                opj('scripts/img2png'),
-               opj('scripts/img2xpm'),
                opj('scripts/img2py'),
-               opj('scripts/xrced'),
-               opj('scripts/pyshell'),
+               opj('scripts/img2xpm'),
+               opj('scripts/pyalacarte'),
+               opj('scripts/pyalamode'),
                opj('scripts/pycrust'),
+               opj('scripts/pyshell'),
                opj('scripts/pywrap'),
                opj('scripts/pywrap'),
-               opj('scripts/pyalacarte'),
-               opj('scripts/pyalamode'),
+               opj('scripts/pywxrc'),
+               opj('scripts/xrced'),
                ]
 
 
+
 DATA_FILES += find_data_files('wx/tools/XRCed', '*.txt', '*.xrc')
 DATA_FILES += find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html')
 DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html')
@@ -664,8 +752,19 @@ else:
               glob.glob(opj("src/_*.py")) + \
               glob.glob(opj("src/*.swg"))
 
-    HEADERS = zip(h_files, ["/include/wx/wxPython"]*len(h_files)) + \
-              zip(i_files, ["/include/wx/wxPython/i_files"]*len(i_files))
+    HEADERS = zip(h_files, ["/wxPython"]*len(h_files)) + \
+              zip(i_files, ["/wxPython/i_files"]*len(i_files))
+
+
+
+if INSTALL_MULTIVERSION:
+    EXTRA_PATH = getExtraPath(addOpts=EP_ADD_OPTS)
+    open("src/wx.pth", "w").write(EXTRA_PATH)
+    CLEANUP.append("src/wx.pth")
+else:
+    EXTRA_PATH = None
+       
+
 
 #----------------------------------------------------------------------
 # Do the Setup/Build/Install/Whatever
@@ -673,6 +772,7 @@ else:
 
 if __name__ == "__main__":
     if not PREP_ONLY:
+        
         setup(name             = 'wxPython',
               version          = VERSION,
               description      = DESCRIPTION,
@@ -698,12 +798,17 @@ if __name__ == "__main__":
                           'wx.lib',
                           'wx.lib.colourchooser',
                           'wx.lib.editor',
+                          'wx.lib.floatcanvas',
+                          'wx.lib.masked',
                           'wx.lib.mixins',
+                          'wx.lib.ogl',
                           'wx.py',
                           'wx.tools',
                           'wx.tools.XRCed',
                           ],
 
+              extra_path = EXTRA_PATH,
+
               ext_package = PKGDIR,
               ext_modules = wxpExtensions,
 
@@ -714,12 +819,40 @@ if __name__ == "__main__":
               data_files = DATA_FILES,
               headers =    HEADERS,
 
-              cmdclass = { 'install_data':    wx_smart_install_data,
+              # Override some of the default distutils command classes with my own
+              cmdclass = { 'install' :        wx_install,
+                           'install_data':    wx_smart_install_data,
                            'install_headers': wx_install_headers,
                            'clean':           wx_extra_clean,
                            },
               )
 
 
+        if INSTALL_MULTIVERSION:
+            setup(name             = 'wxPython-common',
+                  version          = VERSION,
+                  description      = DESCRIPTION,
+                  long_description = LONG_DESCRIPTION,
+                  author           = AUTHOR,
+                  author_email     = AUTHOR_EMAIL,
+                  url              = URL,
+                  download_url     = DOWNLOAD_URL,
+                  license          = LICENSE,
+                  platforms        = PLATFORMS,
+                  classifiers      = filter(None, CLASSIFIERS.split("\n")),
+                  keywords         = KEYWORDS,
+
+                  package_dir = { '': 'wxversion' },
+                  py_modules = ['wxversion'],
+
+                  data_files = [('', ['src/wx.pth'])],
+                  
+                  options = { 'build'            : { 'build_base' : BUILD_BASE },
+                              },
+                  
+                  cmdclass = { 'install_data':    wx_smart_install_data,
+                               },
+                  )
+            
 #----------------------------------------------------------------------
 #----------------------------------------------------------------------