From a99a70dcc8b21b0e7e12bbf25f9f6dad47e6f52c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 13 Aug 2015 07:15:33 +0200 Subject: [PATCH] python: fix ctypes.util.find_library() with musl; patch from Alpine. This patch should also work for glibc, so that it's applied unconditionally. It's unfortunate that this code on glibc relies on `ldconfig -p` to work correctly. --- .../python/patches/musl-find_library.patch | 43 +++++++++++++++++++ srcpkgs/python/template | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/python/patches/musl-find_library.patch diff --git a/srcpkgs/python/patches/musl-find_library.patch b/srcpkgs/python/patches/musl-find_library.patch new file mode 100644 index 00000000000..f5f7f764025 --- /dev/null +++ b/srcpkgs/python/patches/musl-find_library.patch @@ -0,0 +1,43 @@ +See http://bugs.alpinelinux.org/issues/4512 + +--- Lib/ctypes/util.py ++++ Lib/ctypes/util.py +@@ -238,8 +238,37 @@ elif os.name == "posix": + return None + return res.group(1) + ++ 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 f ++ ++ prefix = os.path.join(d, 'lib'+name) ++ for suffix in ['.so', '.so.*', '.*.so.*']: ++ for f in glob('{0}{1}'.format(prefix, suffix)): ++ if _is_elf(f): ++ return f ++ + def find_library(name): +- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) ++ return _find_libfile(name) or _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) + + ################################################################ + # test code diff --git a/srcpkgs/python/template b/srcpkgs/python/template index 0bdb86a9fe5..93deada0325 100644 --- a/srcpkgs/python/template +++ b/srcpkgs/python/template @@ -4,7 +4,7 @@ # pkgname=python version=2.7.10 -revision=6 +revision=7 wrksrc="Python-${version}" hostmakedepends="pkg-config" makedepends="