aboutsummaryrefslogtreecommitdiffstats
path: root/main/python2/musl-find_library.patch
diff options
context:
space:
mode:
authorBartłomiej Piotrowski <b@bpiotrowski.pl>2016-07-18 19:33:46 +0200
committerBartłomiej Piotrowski <b@bpiotrowski.pl>2016-07-18 19:33:46 +0200
commit99dd043cd563c7919bb11bd2478a9e0f9a3dd1c0 (patch)
tree614346077236a57a7c83dab8dfb59d2bdc11474d /main/python2/musl-find_library.patch
parent2c8afec95a601ac9e6ce0d39e761038970f8c0ec (diff)
downloadaports-99dd043cd563c7919bb11bd2478a9e0f9a3dd1c0.tar.bz2
aports-99dd043cd563c7919bb11bd2478a9e0f9a3dd1c0.tar.xz
main/python: rename to python2
Diffstat (limited to 'main/python2/musl-find_library.patch')
-rw-r--r--main/python2/musl-find_library.patch43
1 files changed, 43 insertions, 0 deletions
diff --git a/main/python2/musl-find_library.patch b/main/python2/musl-find_library.patch
new file mode 100644
index 0000000000..2d8d19719c
--- /dev/null
+++ b/main/python2/musl-find_library.patch
@@ -0,0 +1,43 @@
+diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
+index 1e882e3..b265cc0 100644
+--- a/Lib/ctypes/util.py
++++ b/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 os.path.basename(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 os.path.basename(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