ffilib: Initial version of wrapper for ffi module.

pull/27/merge
Damien George 2015-06-04 22:46:08 +01:00
rodzic 2c2f6104f4
commit 6dae7a234e
3 zmienionych plików z 54 dodań i 0 usunięć

29
ffilib/ffilib.py 100644
Wyświetl plik

@ -0,0 +1,29 @@
import sys
import ffi
_cache = {}
def open(name, maxver=10, extra=()):
try:
return _cache[name]
except KeyError:
pass
def libs():
if sys.platform == "linux":
yield '%s.so' % name
for i in range(maxver, -1, -1):
yield '%s.so.%u' % (name, i)
else:
for ext in ('dylib', 'dll'):
yield '%s.%s' % (name, ext)
for n in extra:
yield n
err = None
for n in libs():
try:
l = ffi.open(n)
_cache[name] = l
return l
except OSError as e:
err = e
raise err

Wyświetl plik

@ -0,0 +1,7 @@
dist_name = ffilib
srctype = micropython-lib
type = module
version = 0.1.0
author = Damien George
desc = MicroPython FFI helper module
long_desc = MicroPython FFI helper module to easily interface with underlying shared libraries

18
ffilib/setup.py 100644
Wyświetl plik

@ -0,0 +1,18 @@
import sys
# Remove current dir from sys.path, otherwise setuptools will peek up our
# module instead of system.
sys.path.pop(0)
from setuptools import setup
setup(name='micropython-ffilib',
version='0.1.0',
description='MicroPython FFI helper module',
long_description='MicroPython FFI helper module to easily interface with underlying shared libraries',
url='https://github.com/micropython/micropython/issues/405',
author='Damien George',
author_email='micro-python@googlegroups.com',
maintainer='MicroPython Developers',
maintainer_email='micro-python@googlegroups.com',
license='MIT',
py_modules=['ffilib'])