[Scipy-svn] r5375 - in trunk/scipy/weave: . tests

scipy-svn@scip... scipy-svn@scip...
Thu Jan 8 01:49:27 CST 2009


Author: stefan
Date: 2009-01-08 01:49:11 -0600 (Thu, 08 Jan 2009)
New Revision: 5375

Removed:
   trunk/scipy/weave/tests/test_wx_spec.py
   trunk/scipy/weave/vtk_spec.py
   trunk/scipy/weave/wx_spec.py
Modified:
   trunk/scipy/weave/converters.py
   trunk/scipy/weave/swig2_spec.py
Log:
Remove wx_spec and vtk_spec from weave.

Modified: trunk/scipy/weave/converters.py
===================================================================
--- trunk/scipy/weave/converters.py	2009-01-07 23:55:37 UTC (rev 5374)
+++ trunk/scipy/weave/converters.py	2009-01-08 07:49:11 UTC (rev 5375)
@@ -41,29 +41,6 @@
     pass
 
 #----------------------------------------------------------------------------
-# Add wxPython support
-#
-# RuntimeError can occur if wxPython isn't installed.
-#----------------------------------------------------------------------------
-
-try:
-    # this is currently safe because it doesn't import wxPython.
-    import wx_spec
-    default.insert(0,wx_spec.wx_converter())
-except (RuntimeError,IndexError):
-    pass
-
-#----------------------------------------------------------------------------
-# Add VTK support
-#----------------------------------------------------------------------------
-
-try:
-    import vtk_spec
-    default.insert(0,vtk_spec.vtk_converter())
-except IndexError:
-    pass
-
-#----------------------------------------------------------------------------
 # Add "sentinal" catchall converter
 #
 # if everything else fails, this one is the last hope (it always works)

Modified: trunk/scipy/weave/swig2_spec.py
===================================================================
--- trunk/scipy/weave/swig2_spec.py	2009-01-07 23:55:37 UTC (rev 5374)
+++ trunk/scipy/weave/swig2_spec.py	2009-01-08 07:49:11 UTC (rev 5375)
@@ -2,13 +2,12 @@
 This module allows one to use SWIG2 (SWIG version >= 1.3) wrapped
 objects from Weave.  SWIG-1.3 wraps objects differently from SWIG-1.1.
 
-The code here is based on wx_spec.py.  However, this module is more
-like a template for any SWIG2 wrapped converter.  To wrap any special
-code that uses SWIG the user simply needs to override the defaults in
-the swig2_converter class.  These special circumstances arise when one
-has wrapped code that uses C++ namespaces.  However, for most
-straightforward SWIG wrappers this converter should work fine out of
-the box.
+This module is a template for a SWIG2 wrapped converter.  To wrap any
+special code that uses SWIG the user simply needs to override the
+defaults in the swig2_converter class.  These special circumstances
+arise when one has wrapped code that uses C++ namespaces.  However,
+for most straightforward SWIG wrappers this converter should work fine
+out of the box.
 
 Newer versions of SWIG (>=1.3.22) represent the wrapped object using a
 PyCObject and also a PySwigObject (>=1.3.24).  This code supports all

Deleted: trunk/scipy/weave/tests/test_wx_spec.py
===================================================================
--- trunk/scipy/weave/tests/test_wx_spec.py	2009-01-07 23:55:37 UTC (rev 5374)
+++ trunk/scipy/weave/tests/test_wx_spec.py	2009-01-08 07:49:11 UTC (rev 5375)
@@ -1,123 +0,0 @@
-"""
-check_var_in -- tests whether a variable is passed in correctly
-                and also if the passed in variable can be reassigned
-check_var_local -- tests wheter a variable is passed in , modified,
-                   and returned correctly in the local_dict dictionary
-                   argument
-check_return -- test whether a variable is passed in, modified, and
-                then returned as a function return value correctly
-"""
-
-from numpy.testing import *
-
-e = None
-DONOTRUN = False
-try:
-    from scipy.weave import ext_tools, wx_spec
-    import wx
-except ImportError, e:
-    wx = None
-    DONOTRUN = True
-except RuntimeError, e:
-    wx = None
-    DONOTRUN = True
-
-skip = dec.skipif(DONOTRUN, "(error was %s)" % str(e))
-
-class TestWxConverter(TestCase):
-    def setUp(self):
-        if not DONOTRUN:
-            self.app = wx.App()
-            self.s = wx_spec.wx_converter()
-
-    @dec.slow
-    def test_type_match_string(self):
-        assert(not self.s.type_match('string') )
-
-    @dec.slow
-    def test_type_match_int(self):
-        assert(not self.s.type_match(5))
-
-    @dec.slow
-    def test_type_match_float(self):
-        assert(not self.s.type_match(5.))
-
-    @dec.slow
-    def test_type_match_complex(self):
-        assert(not self.s.type_match(5.+1j))
-
-    @dec.slow
-    def test_type_match_complex(self):
-        assert(not self.s.type_match(5.+1j))
-
-    @dec.slow
-    def test_type_match_wxframe(self):
-        f=wx.Frame(None,-1,'bob')
-        assert(self.s.type_match(f))
-
-    @dec.slow
-    def test_var_in(self):
-        mod = ext_tools.ext_module('wx_var_in',compiler='')
-        mod.customize.add_header('<wx/string.h>')
-        mod.customize.add_extra_compile_arg(' '.join(self.s.extra_compile_args))
-        mod.customize.add_extra_link_arg(' '.join(self.s.extra_link_args))
-
-        a = wx.Frame(None,-1,'bob')
-        code = """
-               py::tuple args(1);
-               args[0] = py::object("jim");
-               a.mcall("SetTitle",args);
-               """
-        test = ext_tools.ext_function('test',code,['a'],locals(),globals())
-        mod.add_function(test)
-        mod.compile()
-        import wx_var_in
-        b=a
-        wx_var_in.test(b)
-        assert(b.GetTitle() == "jim")
-        try:
-            b = 1.
-            wx_var_in.test(b)
-        except AttributeError:
-            pass
-        try:
-            b = 1
-            wx_var_in.test(b)
-        except AttributeError:
-            pass
-
-    @dec.slow
-    def no_check_var_local(self):
-        mod = ext_tools.ext_module('wx_var_local')
-        a = 'string'
-        code = 'a="hello";'
-        var_specs = ext_tools.assign_variable_types(['a'],locals())
-        test = ext_tools.ext_function_from_specs('test',code,var_specs)
-        mod.add_function(test)
-        mod.compile()
-        import wx_var_local
-        b='bub'
-        q={}
-        wx_var_local.test(b,q)
-        assert('a' == 'string')
-
-    @dec.slow
-    def no_test_no_check_return(self):
-        mod = ext_tools.ext_module('wx_return')
-        a = 'string'
-        code = """
-               a= Py::wx("hello");
-               return_val = Py::new_reference_to(a);
-               """
-        test = ext_tools.ext_function('test',code,['a'],locals())
-        mod.add_function(test)
-        mod.compile()
-        import wx_return
-        b='bub'
-        c = wx_return.test(b)
-        assert(c == 'hello')
-
-decorate_methods(TestWxConverter, skip)
-
-if __name__ == "__main__":
-    nose.run(argv=['', __file__])

Deleted: trunk/scipy/weave/vtk_spec.py
===================================================================
--- trunk/scipy/weave/vtk_spec.py	2009-01-07 23:55:37 UTC (rev 5374)
+++ trunk/scipy/weave/vtk_spec.py	2009-01-08 07:49:11 UTC (rev 5375)
@@ -1,130 +0,0 @@
-"""
-VTK type converter.
-
-This module handles conversion between VTK C++ and VTK Python objects
-so that one can write inline C++ code to manipulate VTK Python
-objects.  It requires that you have VTK and the VTK-Python wrappers
-installed.  It has been tested with VTK 4.0 and above.  The code is
-based on wx_spec.py.  You will need to call inline with include_dirs,
-library_dirs and often even libraries appropriately set for this to
-work without errors.  Sometimes you might need to include additional
-headers.
-
-Distributed under the SciPy License.
-
-Authors:
-  Prabhu Ramachandran <prabhu@aero.iitm.ernet.in>
-  Eric Jones <eric@enthought.com>
-"""
-
-from c_spec import common_base_converter
-
-
-vtk_py_to_c_template = \
-"""
-class %(type_name)s_handler
-{
-public:
-    %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)
-    {
-        %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, "%(type_name)s");
-        if (!vtk_ptr)
-            handle_conversion_error(py_obj,"%(type_name)s", name);
-        %(inc_ref_count)s
-        return vtk_ptr;
-    }
-
-    %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)
-    {
-        %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, "%(type_name)s");
-        if (!vtk_ptr)
-            handle_bad_type(py_obj,"%(type_name)s", name);
-        %(inc_ref_count)s
-        return vtk_ptr;
-    }
-};
-
-%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();
-#define convert_to_%(type_name)s(py_obj,name) \\
-        x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)
-#define py_to_%(type_name)s(py_obj,name) \\
-        x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)
-
-"""
-
-vtk_c_to_py_template = \
-"""
-PyObject* %(type_name)s_to_py(vtkObjectBase* obj)
-{
-    return vtkPythonGetObjectFromPointer(obj);
-}
-"""
-
-
-class vtk_converter(common_base_converter):
-    def __init__(self,class_name="undefined"):
-        self.class_name = class_name
-        common_base_converter.__init__(self)
-
-    def init_info(self):
-        common_base_converter.init_info(self)
-        # These are generated on the fly instead of defined at
-        # the class level.
-        self.type_name = self.class_name
-        self.c_type = self.class_name + "*"
-        self.return_type = self.c_type
-        self.to_c_return = None # not used
-        self.check_func = None # not used
-        hdr = self.class_name + ".h"
-        # Remember that you need both the quotes!
-        self.headers.extend(['"vtkPythonUtil.h"', '"vtkObject.h"',
-                             '"%s"'%hdr])
-        #self.include_dirs.extend(vtk_inc)
-        #self.define_macros.append(('SOME_VARIABLE', '1'))
-        #self.library_dirs.extend(vtk_lib)
-        self.libraries.extend(['vtkCommonPython', 'vtkCommon'])
-        #self.support_code.append(common_info.swig_support_code)
-
-    def type_match(self,value):
-        is_match = 0
-        try:
-            if value.IsA('vtkObject'):
-                is_match = 1
-        except AttributeError:
-            pass
-        return is_match
-
-    def generate_build_info(self):
-        if self.class_name != "undefined":
-            res = common_base_converter.generate_build_info(self)
-        else:
-            # if there isn't a class_name, we don't want the
-            # we don't want the support_code to be included
-            import base_info
-            res = base_info.base_info()
-        return res
-
-    def py_to_c_code(self):
-        return vtk_py_to_c_template % self.template_vars()
-
-    def c_to_py_code(self):
-        return vtk_c_to_py_template % self.template_vars()
-
-    def type_spec(self,name,value):
-        # factory
-        class_name = value.__class__.__name__
-        new_spec = self.__class__(class_name)
-        new_spec.name = name
-        return new_spec
-
-    def __cmp__(self,other):
-        #only works for equal
-        res = -1
-        try:
-            res = cmp(self.name,other.name) or \
-                  cmp(self.__class__, other.__class__) or \
-                  cmp(self.class_name, other.class_name) or \
-                  cmp(self.type_name,other.type_name)
-        except:
-            pass
-        return res

Deleted: trunk/scipy/weave/wx_spec.py
===================================================================
--- trunk/scipy/weave/wx_spec.py	2009-01-07 23:55:37 UTC (rev 5374)
+++ trunk/scipy/weave/wx_spec.py	2009-01-08 07:49:11 UTC (rev 5375)
@@ -1,184 +0,0 @@
-import common_info
-from c_spec import common_base_converter
-import sys,os
-import glob
-
-def find_base_dir():
-    searched_locations = ['c:\third\wxpython*',
-                          '/usr/lib/wx*']
-
-    candidate_locations = []
-    for pattern in searched_locations:
-        candidate_locations.extend(glob.glob(pattern))
-    candidate_locations.sort()
-
-    if len(candidate_locations) == 0:
-        raise RuntimeError("Could not locate wxPython base directory.")
-    else:
-        return candidate_locations[-1]
-
-wx_base = find_base_dir()
-
-def get_wxconfig(flag):
-    wxconfig = os.path.join(wx_base,'bin','wx-config')
-    if not os.path.exists(wxconfig):
-        # Could not locate wx-config, assume it is on the path.
-        wxconfig = 'wx-config'
-
-    import commands
-    res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)
-    if res:
-        msg = wxconfig + ' failed. Impossible to learn wxPython settings'
-        raise RuntimeError, msg
-    return settings.split()
-
-wx_to_c_template = \
-"""
-class %(type_name)s_handler
-{
-public:
-    %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)
-    {
-        %(c_type)s wx_ptr;
-        // work on this error reporting...
-        if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,"_%(type_name)s_p"))
-            handle_conversion_error(py_obj,"%(type_name)s", name);
-        %(inc_ref_count)s
-        return wx_ptr;
-    }
-
-    %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)
-    {
-        %(c_type)s wx_ptr;
-        // work on this error reporting...
-        if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,"_%(type_name)s_p"))
-            handle_bad_type(py_obj,"%(type_name)s", name);
-        %(inc_ref_count)s
-        return wx_ptr;
-    }
-};
-
-%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();
-#define convert_to_%(type_name)s(py_obj,name) \\
-        x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)
-#define py_to_%(type_name)s(py_obj,name) \\
-        x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)
-
-"""
-
-class wx_converter(common_base_converter):
-    def __init__(self,class_name="undefined"):
-        self.class_name = class_name
-        common_base_converter.__init__(self)
-
-    def init_info(self):
-        common_base_converter.init_info(self)
-        # These are generated on the fly instead of defined at
-        # the class level.
-        self.type_name = self.class_name
-        self.c_type = self.class_name + "*"
-        self.return_type = self.class_name + "*"
-        self.to_c_return = None # not used
-        self.check_func = None # not used
-        self.headers.append('"wx/wx.h"')
-        if sys.platform == "win32":
-            # These will be used in many cases
-            self.headers.append('<windows.h>')
-
-            # These are needed for linking.
-            self.libraries.extend(['kernel32','user32','gdi32','comdlg32',
-                                   'winspool', 'winmm', 'shell32',
-                                   'oldnames', 'comctl32', 'ctl3d32',
-                                   'odbc32', 'ole32', 'oleaut32',
-                                   'uuid', 'rpcrt4', 'advapi32', 'wsock32'])
-
-            # not sure which of these macros are needed.
-            self.define_macros.append(('WIN32', '1'))
-            self.define_macros.append(('__WIN32__', '1'))
-            self.define_macros.append(('_WINDOWS', '1'))
-            self.define_macros.append(('STRICT', '1'))
-            # I think this will only work on NT/2000/XP set
-            # set to 0x0400 for earlier versions.
-            # Hmmm.  setting this breaks stuff
-            #self.define_macros.append(('WINVER', '0x0350'))
-
-            self.library_dirs.append(os.path.join(wx_base,'lib'))
-            #self.include_dirs.append(os.path.join(wx_base,'include'))
-            self.include_dirs.append(wx_base)
-            self.include_dirs.append(os.path.join(wx_base,'include'))
-            self.include_dirs.append(os.path.join(wx_base,'include','msw'))
-            # how do I discover unicode or not unicode??
-            # non-unicode
-            self.libraries.append('wxmsw24h')
-            self.include_dirs.append(os.path.join(wx_base,'lib'))
-
-            # unicode
-            #self.libraries.append('wxmswuh')
-            #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))
-            #self.define_macros.append(('UNICODE', '1'))
-        else:
-            # make sure the gtk files are available
-            # ?? Do I need to link to them?
-            self.headers.append('"gdk/gdk.h"')
-            # !! This shouldn't be hard coded.
-            self.include_dirs.append("/usr/include/gtk-1.2")
-            self.include_dirs.append("/usr/include/glib-1.2")
-            self.include_dirs.append("/usr/lib/glib/include")
-            cxxflags = get_wxconfig('cxxflags')
-            libflags = get_wxconfig('libs') + get_wxconfig('gl-libs')
-
-            #older versions of wx do not support the ldflags.
-            try:
-                ldflags = get_wxconfig('ldflags')
-            except RuntimeError:
-                ldflags = []
-
-            self.extra_compile_args.extend(cxxflags)
-            self.extra_link_args.extend(libflags)
-            self.extra_link_args.extend(ldflags)
-        self.support_code.append(common_info.swig_support_code)
-
-    def type_match(self,value):
-        is_match = 0
-        try:
-            wx_class = str(value.this).split('_')[-1]
-            if wx_class[:2] == 'wx':
-                is_match = 1
-        except AttributeError:
-            pass
-        return is_match
-
-    def generate_build_info(self):
-        if self.class_name != "undefined":
-            res = common_base_converter.generate_build_info(self)
-        else:
-            # if there isn't a class_name, we don't want the
-            # we don't want the support_code to be included
-            import base_info
-            res = base_info.base_info()
-        return res
-
-    def py_to_c_code(self):
-        return wx_to_c_template % self.template_vars()
-
-    #def c_to_py_code(self):
-    #    return simple_c_to_py_template % self.template_vars()
-
-    def type_spec(self,name,value):
-        # factory
-        class_name = str(value.this).split('_')[-1]
-        new_spec = self.__class__(class_name)
-        new_spec.name = name
-        return new_spec
-
-    def __cmp__(self,other):
-        #only works for equal
-        res = -1
-        try:
-            res = cmp(self.name,other.name) or \
-                  cmp(self.__class__, other.__class__) or \
-                  cmp(self.class_name, other.class_name) or \
-                  cmp(self.type_name,other.type_name)
-        except:
-            pass
-        return res



More information about the Scipy-svn mailing list