SamehK | 6 Sep 20:54 2009
Picon

Re: [SciPy-user] Weave Inline with MSVC


So, someone broke the current weave under windows by introducing code that is
gcc-specific!
In inline_tools.py, modify lines 84 and 87 by removing "__attribute__
((unused))" from both if you want inline to work with VS.

        try_code =    'try                              \n' \
                      '{                                \n' \
                      '    PyObject* raw_locals __attribute__ ((unused));\n'
\
                      '    raw_locals = py_to_raw_dict('       \
                                             'py__locals,"_locals");\n'  \
                      '    PyObject* raw_globals __attribute__
((unused));\n' \

Hope this helps someone out. I already wasted a day on this nonsense.

SamehK wrote:
> 
> By checking the generated cpp file, I was wondering if there's a bug
> somewhere that causes weave to dump "__attribute__" and "unused" when they
> haven't been defined.
> 
> The cpp file:
> static PyObject* compiled_func(PyObject*self, PyObject* args)
> {
>     py::object return_val;
>     int exception_occured = 0;
>     PyObject *py__locals = NULL;
>     PyObject *py__globals = NULL;
>    
> if(!PyArg_ParseTuple(args,"OO:compiled_func",&py__locals,&py__globals))
>         return NULL;
>     try                              
>     {                                
>         PyObject* raw_locals __attribute__ ((unused));
>         raw_locals = py_to_raw_dict(py__locals,"_locals");
>         PyObject* raw_globals __attribute__ ((unused));
>         raw_globals = py_to_raw_dict(py__globals,"_globals");
>         /* argument conversion code */     
>         /* inline code */                   
>         /* NDARRAY API VERSION 1000009 */
>         int i;    /*I would like to fill in changed    locals and globals
> here...*/   
>     
>     }                                       
>     catch(...)                        
>     {                                 
>         return_val =  py::object();   
>         exception_occured = 1;        
>     }                                 
>     /* cleanup code */                   
>     if(!(PyObject*)return_val && !exception_occured)
>     {
>                                   
>         return_val = Py_None;            
>     }
>                                   
>     return return_val.disown();          
> }
> 
> 
> 
> SamehK wrote:
>> 
>> Hi everyone,
>> I was just trying out weave since I could use the speedup for a project,
>> but the simplest example fails. I was wondering if it's an
>> incompatibility with VS 2008. I am using Python 2.6.2, Scipy 0.7.1, Numpy
>> 1.3.0b1, which I believe are all the latest stable versions.
>> 
>> from scipy.weave import inline
>> inline("int i;")
>> 
>> No module named msvccompiler in numpy.distutils; trying from distutils
>> Missing compiler_cxx fix for MSVCCompiler
>> Found executable C:\Programs\Microsoft Visual Studio 9.0\VC\BIN\cl.exe
>> sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp
>> C:\Programs\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning
>> C4530: C++ exception handler used, but unwind semantics are not enabled.
>> Specify /EHsc
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(653) :
>> error C2146: syntax error : missing ';' before identifier '__attribute__'
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(653) :
>> error C2065: 'unused' : undeclared identifier
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(653) :
>> error C3861: '__attribute__': identifier not found
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(655) :
>> error C2146: syntax error : missing ';' before identifier '__attribute__'
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(655) :
>> error C2065: 'unused' : undeclared identifier
>> ...\python26_compiled\sc_40d3d8fa3c65de8979d50fc530eb0b7f12.cpp(655) :
>> error C3861: '__attribute__': identifier not found
>> 
>> I also tried the print_example.py in site-packages\scipy\weave\examples
>> and it also fails, however, the fibonacci.py example that uses ext_tools
>> works fine. What am I missing?
>> 
>> Thank you.
>> Sam 
>> 
> 
> 

--

-- 
View this message in context: http://www.nabble.com/Weave-Inline-with-MSVC-tp25318825p25320644.html
Sent from the Scipy-User mailing list archive at Nabble.com.

Gmane