kopia lustrzana https://github.com/micropython/micropython-lib
ffilib: Initial version of wrapper for ffi module.
rodzic
2c2f6104f4
commit
6dae7a234e
|
@ -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
|
|
@ -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
|
|
@ -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'])
|
Ładowanie…
Reference in New Issue