aboutsummaryrefslogtreecommitdiffstats
path: root/main/python3/musl-find_library.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-11-03 08:25:00 +0200
committerTimo Teräs <timo.teras@iki.fi>2016-11-03 08:25:41 +0200
commit4e5b5562adeaa22a6ea6715b85efcc757d96e220 (patch)
treecbb1d3daf6e3047e36958f0c8a61361f644d7727 /main/python3/musl-find_library.patch
parent6b5de6bfe288a6dbd51dce104669c519f836ae51 (diff)
downloadaports-4e5b5562adeaa22a6ea6715b85efcc757d96e220.tar.bz2
aports-4e5b5562adeaa22a6ea6715b85efcc757d96e220.tar.xz
main/python3: add slightly improved musl find_library fix
ref #5264
Diffstat (limited to 'main/python3/musl-find_library.patch')
-rw-r--r--main/python3/musl-find_library.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/main/python3/musl-find_library.patch b/main/python3/musl-find_library.patch
new file mode 100644
index 0000000000..dbaf0286e5
--- /dev/null
+++ b/main/python3/musl-find_library.patch
@@ -0,0 +1,45 @@
+diff -ru Python-3.5.2.orig/Lib/ctypes/util.py Python-3.5.2/Lib/ctypes/util.py
+--- Python-3.5.2.orig/Lib/ctypes/util.py 2016-06-26 00:38:35.000000000 +0300
++++ Python-3.5.2/Lib/ctypes/util.py 2016-11-03 08:21:50.046469019 +0200
+@@ -204,6 +204,41 @@
+ def find_library(name, is64 = False):
+ 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):
++ try:
++ with open(filepath, 'rb') as fh:
++ return fh.read(4) == b'\x7fELF'
++ except:
++ return False
++
++ def _find_libfile(name):
++ from glob import glob
++ # special case for libm, libcrypt and libpthread and musl
++ if name in ['m', 'crypt', 'pthread']:
++ name = 'c'
++ elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
++ name = 'libc.so'
++ # search in standard locations
++ paths = ['/lib', '/usr/lib', '/usr/local/lib']
++ if 'LD_LIBRARY_PATH' in os.environ:
++ paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
++ for d in paths:
++ f = os.path.join(d, name)
++ if _is_elf(f):
++ return os.path.basename(f)
++
++ prefix = os.path.join(d, 'lib'+name)
++ for suffix in ['.so', '.so.*']:
++ for f in glob('{0}{1}'.format(prefix, suffix)):
++ if _is_elf(f):
++ return os.path.basename(f)
++
++ def find_library(name):
++ return _find_libfile(name)
++
+ else:
+
+ def _findSoname_ldconfig(name):