python: sync musl find_library fix (via Alpine)
This commit is contained in:
parent
d757e81847
commit
93305fd847
2 changed files with 17 additions and 16 deletions
|
@ -1,11 +1,12 @@
|
||||||
http://bugs.alpinelinux.org/issues/5038
|
--- Lib/ctypes/util.py.orig
|
||||||
|
|
||||||
--- Lib/ctypes/util.py
|
|
||||||
+++ Lib/ctypes/util.py
|
+++ Lib/ctypes/util.py
|
||||||
@@ -238,8 +238,37 @@ elif os.name == "posix":
|
@@ -204,6 +204,41 @@
|
||||||
return None
|
def find_library(name, is64 = False):
|
||||||
return res.group(1)
|
return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
|
||||||
|
|
||||||
|
+ elif True:
|
||||||
|
+
|
||||||
|
+ # Patched for Alpine Linux / musl - search manually system paths
|
||||||
+ def _is_elf(filepath):
|
+ def _is_elf(filepath):
|
||||||
+ try:
|
+ try:
|
||||||
+ with open(filepath, 'rb') as fh:
|
+ with open(filepath, 'rb') as fh:
|
||||||
|
@ -13,15 +14,18 @@ http://bugs.alpinelinux.org/issues/5038
|
||||||
+ except:
|
+ except:
|
||||||
+ return False
|
+ return False
|
||||||
+
|
+
|
||||||
+ def _find_libfile(name):
|
+ def find_library(name):
|
||||||
+ from glob import glob
|
+ from glob import glob
|
||||||
|
+ # absolute name?
|
||||||
|
+ if os.path.isabs(name):
|
||||||
|
+ return name
|
||||||
+ # special case for libm, libcrypt and libpthread and musl
|
+ # special case for libm, libcrypt and libpthread and musl
|
||||||
+ if name in ['m', 'crypt', 'pthread']:
|
+ if name in ['m', 'crypt', 'pthread']:
|
||||||
+ name = 'c'
|
+ name = 'c'
|
||||||
+ elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
|
+ elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
|
||||||
+ name = 'libc.so'
|
+ name = 'libc.so'
|
||||||
+ # search in standard locations
|
+ # search in standard locations (musl order)
|
||||||
+ paths = ['/lib', '/usr/lib', '/usr/local/lib']
|
+ paths = ['/lib', '/usr/local/lib', '/usr/lib']
|
||||||
+ if 'LD_LIBRARY_PATH' in os.environ:
|
+ if 'LD_LIBRARY_PATH' in os.environ:
|
||||||
+ paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
|
+ paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
|
||||||
+ for d in paths:
|
+ for d in paths:
|
||||||
|
@ -30,14 +34,11 @@ http://bugs.alpinelinux.org/issues/5038
|
||||||
+ return os.path.basename(f)
|
+ return os.path.basename(f)
|
||||||
+
|
+
|
||||||
+ prefix = os.path.join(d, 'lib'+name)
|
+ prefix = os.path.join(d, 'lib'+name)
|
||||||
+ for suffix in ['.so', '.so.*', '.*.so.*']:
|
+ for suffix in ['.so', '.so.*']:
|
||||||
+ for f in glob('{0}{1}'.format(prefix, suffix)):
|
+ for f in glob('{0}{1}'.format(prefix, suffix)):
|
||||||
+ if _is_elf(f):
|
+ if _is_elf(f):
|
||||||
+ return os.path.basename(f)
|
+ return os.path.basename(f)
|
||||||
+
|
+
|
||||||
def find_library(name):
|
else:
|
||||||
- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
|
||||||
+ return _find_libfile(name) or _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
|
||||||
|
|
||||||
################################################################
|
def _findSoname_ldconfig(name):
|
||||||
# test code
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
pkgname=python
|
pkgname=python
|
||||||
version=2.7.12
|
version=2.7.12
|
||||||
revision=2
|
revision=3
|
||||||
wrksrc="Python-${version}"
|
wrksrc="Python-${version}"
|
||||||
hostmakedepends="pkg-config"
|
hostmakedepends="pkg-config"
|
||||||
makedepends="
|
makedepends="
|
||||||
|
|
Loading…
Reference in a new issue