[Pyrex] [Mac Inter Core Duo OS 10.4.9 ] Next question: cmd line build of init

David Goldsmith David.L.Goldsmith at noaa.gov
Wed Jun 6 18:07:33 UTC 2007


OK, so now I have:

In SolveSAC_Wrap.pyx:

*# Pyrex wrapper for SolveSAC

import BMMain as BMM

test_vals = BMM.BMGlobalInputsWrapper()
test_vals.getAllInputs("/Users/dg/Documents/NOAA/Projects/BaroModes/software/BMS
ettingsFile.asc")

def GetNumVertices():
    return _GetNumVertices()

cdef public long _GetNumVertices():
    if test_vals.nodes:
        return test_vals.d.getNrows()

*and in run_SolveSAC_Wrap.py:

*import SolveSAC_Wrap as SSW

print SSW.GetNumVertices()
*
and I still get:

$ python run_SolveSAC_Wrap.py
Traceback (most recent call last):
  File "run_SolveSAC_Wrap.py", line 1, in <module>
    import SolveSAC_Wrap as SSW
ImportError: dynamic module does not define init function 
(initSolveSAC_Wrap)

DG
Francesc Altet wrote:
> El dc 06 de 06 del 2007 a les 09:52 -0700, en/na David Goldsmith va
> escriure:
>   
>> Francesc Altet wrote:
>>     
>>> [Please always reply to the list so that other people and help/learn
>>> to/from you]
>>>   
>>>       
>> Sorry, I thought I did (I usually do) but I guess I forgot to this time. :-)
>>     
>>> The problem is that you have defined GetNumVertices() as 'cdef' function
>>> instead of 'def'.  'cdef' is the way to declare C functions but these
>>> will not be callable from Python. Try this:
>>>   
>>>       
>> What if I want it to be callable from both?
>>     
>
> In that case, you can do a wrapper in the next way:
>
> def GetNumVertices():
>     return _GetNumVertices()    
>
> cdef public long _GetNumVertices():
>     if test_vals.nodes:
>         return test_vals.d.getNrows()
>
> If you want to call from Python, call GetNumVertices(). If you want to
> call the function from C, then call _GetNumVertices().
>
> Cheers,
>
>   

-- 
ERD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20070606/37de731c/attachment-0001.html 


More information about the Pyrex mailing list