From a28fd5497d1da29770ed1ae191835364bbc50d79 Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Thu, 17 Nov 2016 16:52:52 +0100 Subject: [PATCH] python3: fix find_library with musl (via Alpine) --- .../python3/patches/musl-find_library.patch | 44 +++++++++++++++++++ srcpkgs/python3/template | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/python3/patches/musl-find_library.patch diff --git a/srcpkgs/python3/patches/musl-find_library.patch b/srcpkgs/python3/patches/musl-find_library.patch new file mode 100644 index 0000000000..ec9f3d94f1 --- /dev/null +++ b/srcpkgs/python3/patches/musl-find_library.patch @@ -0,0 +1,44 @@ +--- Lib/ctypes/util.py.orig ++++ Lib/ctypes/util.py +@@ -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_library(name): ++ from glob import glob ++ # absolute name? ++ if os.path.isabs(name): ++ return name ++ # 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 (musl order) ++ paths = ['/lib', '/usr/local/lib', '/usr/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) ++ + else: + + def _findSoname_ldconfig(name): diff --git a/srcpkgs/python3/template b/srcpkgs/python3/template index 2241431310..d641559915 100644 --- a/srcpkgs/python3/template +++ b/srcpkgs/python3/template @@ -1,7 +1,7 @@ # Template file for 'python3' pkgname=python3 version=3.5.2 -revision=2 +revision=3 wrksrc="Python-${version}" short_desc="Interpreted, interactive, object-oriented programming language (${version%.*} series)" maintainer="Juan RP "