upip: Drop _libc, add ffilib.

pull/43/head
Paul Sokolovsky 2015-08-30 03:15:37 +03:00
rodzic 2c00116f52
commit 5633db3aec
3 zmienionych plików z 42 dodań i 35 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ all:
# This target prepares snapshot of all dependency modules, for
# self-contained install
deps: upip__libc.py upip_os.py upip_os_path.py upip_errno.py upip_gzip.py upip_stat.py upip_utarfile.py
deps: upip_ffilib.py upip_os.py upip_os_path.py upip_errno.py upip_gzip.py upip_stat.py upip_utarfile.py
upip_ffilib.py: ../ffilib/ffilib.py
cp $^ $@

Wyświetl plik

@ -1,34 +0,0 @@
import ffi
import sys
_h = None
names = ('libc.so', 'libc.so.0', 'libc.so.6', 'libc.dylib')
def get():
global _h
if _h:
return _h
err = None
for n in names:
try:
_h = ffi.open(n)
return _h
except OSError as e:
err = e
raise err
def set_names(n):
global names
names = n
# Find out bitness of the platform, even if long ints are not supported
# TODO: All bitness differences should be removed from micropython-lib, and
# this snippet too.
bitness = 1
v = sys.maxsize
while v:
bitness += 1
v >>= 1

Wyświetl plik

@ -0,0 +1,41 @@
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
def libc():
return open("libc", 6)
# Find out bitness of the platform, even if long ints are not supported
# TODO: All bitness differences should be removed from micropython-lib, and
# this snippet too.
bitness = 1
v = sys.maxsize
while v:
bitness += 1
v >>= 1