Hakan Ardo
unread,Sep 27, 2012, 8:11:07 AM9/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pytho...@googlegroups.com
Hi,
I'm having issues with enums. I have tst.py containing:
from cffi import FFI
ffi = FFI()
ffi.cdef("""
typedef enum {DT_MEIJSTER_2000, ...} dt_algorithm;
""")
lib = ffi.verify("""
typedef enum {DT_MEIJSTER_2000, FOO} dt_algorithm;
""")
which works when used localy:
$ python -c 'import tst; print tst.lib.DT_MEIJSTER_2000'
0
When I install it using "python setup.y install" with setup.py containing:
from distutils.core import setup
import tst
setup(name='bsdopendirtype',
py_modules=['tst'],
ext_modules=[tst.ffi.verifier.get_extension()])
and try to use the centrally installed version, it fails:
$ cd /tmp
$ python -c 'import tst; print tst.lib.DT_MEIJSTER_2000'
[...]
File "/usr/local/lib/python2.7/dist-packages/cffi-0.4-py2.7-linux-x86_64.egg/cffi/vengine_cpy.py",
line 583, in _loading_cpy_enum
for enumerator in tp.enumerators]
AttributeError: 'module' object has no attribute 'DT_MEIJSTER_2000'
If I replace the cdef with:
ffi.cdef("""
typedef int dt_algorithm;
static const int DT_MEIJSTER_2000;
""")
it works as expected.
--
Håkan Ardö