[pypy-dev] question on using ctypes
Jiwon Seo
seojiwon at gmail.com
Tue Jul 4 17:55:40 CEST 2006
Hi,
I added a module that uses ctypes under pypy/module/ but I'm getting
ImportError while running translate.py for targetpypystandalone.py
The error message is like,
..... cut ...
[translation:ERROR] w_value = loader(space)
[translation:ERROR] File
"/u/jiwon/proj/pypy-dist/pypy/interpreter/mixedmodule.py", line 135,
in ifileloader
[translation:ERROR] d[name] = __import__(name, None, None, [name])
[translation:ERROR] ImportError': No module named tcc
[translation:ERROR] .. v0 = getattr(self_0, ('w_dict'))
[translation:ERROR] Processing block:
[translation:ERROR] block at -1 is a <class
'pypy.objspace.flow.flowcontext.SpamBlock'>
[translation:ERROR] in
(pypy.interpreter.mixedmodule:33)MixedModule.MixedModule.getdictvalue
[translation:ERROR] containing the following operations:
[translation:ERROR] v1 = getattr(space_0, ('finditem'))
[translation:ERROR] v0 = getattr(self_0, ('w_dict'))
[translation:ERROR] v2 = simple_call(v1, v0, w_name_0)
[translation:ERROR] v3 = getattr(self_0, ('lazy'))
[translation:ERROR] v4 = is_true(v3)
[translation:ERROR] --end--
and the part I added is pypy/module/tcc/__init__.py and pypy/module/tcc/tcc.py
### __init__.py
# Package initialisation
from pypy.interpreter.mixedmodule import MixedModule
class Module(MixedModule):
appleveldefs = {}
interpleveldefs = {
'print0': 'tcc.tcc_print0'
}
### tcc.py
from pypy.interpreter.baseobjspace import ObjSpace
from ctypes import *
libtcc = CDLL('/path/to/lib.so')
print0 = libtcc.TCC_Print
print0.argtypes = [c_char_p]
print0.restype = c_int
def tcc_print0(space, msg):
print0(msg)
tcc_print0.unwrap_spec = [ObjSpace, str]
What have I done wrong?
Thaniks,
-Jiwon
More information about the Pypy-dev
mailing list