File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ import ffi
3+
4+ _cache = {}
5+
6+ def open (name , maxver = 10 , extra = ()):
7+ try :
8+ return _cache [name ]
9+ except KeyError :
10+ pass
11+ def libs ():
12+ if sys .platform == "linux" :
13+ yield '%s.so' % name
14+ for i in range (maxver , - 1 , - 1 ):
15+ yield '%s.so.%u' % (name , i )
16+ else :
17+ for ext in ('dylib' , 'dll' ):
18+ yield '%s.%s' % (name , ext )
19+ for n in extra :
20+ yield n
21+ err = None
22+ for n in libs ():
23+ try :
24+ l = ffi .open (n )
25+ _cache [name ] = l
26+ return l
27+ except OSError as e :
28+ err = e
29+ raise err
Original file line number Diff line number Diff line change 1+ dist_name = ffilib
2+ srctype = micropython-lib
3+ type = module
4+ version = 0.1.0
5+ author = Damien George
6+ desc = MicroPython FFI helper module
7+ long_desc = MicroPython FFI helper module to easily interface with underlying shared libraries
Original file line number Diff line number Diff line change 1+ import sys
2+ # Remove current dir from sys.path, otherwise setuptools will peek up our
3+ # module instead of system.
4+ sys .path .pop (0 )
5+ from setuptools import setup
6+
7+
8+ setup (name = 'micropython-ffilib' ,
9+ version = '0.1.0' ,
10+ description = 'MicroPython FFI helper module' ,
11+ long_description = 'MicroPython FFI helper module to easily interface with underlying shared libraries' ,
12+ url = 'https://github.com/micropython/micropython/issues/405' ,
13+ author = 'Damien George' ,
14+ author_email = 'micro-python@googlegroups.com' ,
15+ maintainer = 'MicroPython Developers' ,
16+ maintainer_email = 'micro-python@googlegroups.com' ,
17+ license = 'MIT' ,
18+ py_modules = ['ffilib' ])
You can’t perform that action at this time.
0 commit comments