diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py --- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300 +++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +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_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.*','.a']: + 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/Modules/posixmodule.c b/Modules/posixmodule.c index 8f8ba25..72b92da 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -103,8 +103,9 @@ corresponding Unix manual entries for more information on calls."); #undef HAVE_SCHED_SETAFFINITY #endif -#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) +#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) #define USE_XATTRS +#include #endif #ifdef USE_XATTRS --- a/Modules/Setup 2020-07-20 13:01:32.000000000 +0000 +++ b/Modules/Setup 2020-09-01 06:01:22.610144384 +0000 @@ -1,3 +1,4 @@ +*static* # -*- makefile -*- # The file Setup is used by the makesetup script to construct the files # Makefile and config.c, from Makefile.pre and config.c.in, @@ -166,66 +167,65 @@ # Modules that should always be present (non UNIX dependent): -#array arraymodule.c # array objects -#cmath cmathmodule.c _math.c # -lm # complex math library functions -#math mathmodule.c _math.c # -lm # math library functions, e.g. sin() -#_contextvars _contextvarsmodule.c # Context Variables -#_struct _struct.c # binary structure packing/unpacking -#_weakref _weakref.c # basic weak reference support +array arraymodule.c # array objects +cmath cmathmodule.c _math.c # -lm # complex math library functions +math mathmodule.c _math.c # -lm # math library functions, e.g. sin() +_contextvars _contextvarsmodule.c # Context Variables +_struct _struct.c # binary structure packing/unpacking +_weakref _weakref.c # basic weak reference support #_testcapi _testcapimodule.c # Python C API test module #_testinternalcapi _testinternalcapi.c -I$(srcdir)/Include/internal -DPy_BUILD_CORE_MODULE # Python internal C API test module -#_random _randommodule.c # Random number generator -#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator -#_pickle _pickle.c # pickle accelerator -#_datetime _datetimemodule.c # datetime accelerator -#_bisect _bisectmodule.c # Bisection algorithms -#_heapq _heapqmodule.c # Heap queue algorithm -#_asyncio _asynciomodule.c # Fast asyncio Future -#_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c # _json speedups -#_statistics _statisticsmodule.c # statistics accelerator +_random _randommodule.c # Random number generator +_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator +_pickle _pickle.c # pickle accelerator +_datetime _datetimemodule.c # datetime accelerator +_bisect _bisectmodule.c # Bisection algorithms +_heapq _heapqmodule.c # Heap queue algorithm +_asyncio _asynciomodule.c # Fast asyncio Future +_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c # _json speedups +_statistics _statisticsmodule.c # statistics accelerator -#unicodedata unicodedata.c # static Unicode character database +unicodedata unicodedata.c # static Unicode character database # Modules with some UNIX dependencies -- on by default: # (If you have a really backward UNIX, select and socket may not be # supported...) -#fcntl fcntlmodule.c # fcntl(2) and ioctl(2) -#spwd spwdmodule.c # spwd(3) -#grp grpmodule.c # grp(3) -#select selectmodule.c # select(2); not on ancient System V +fcntl fcntlmodule.c # fcntl(2) and ioctl(2) +spwd spwdmodule.c # spwd(3) +grp grpmodule.c # grp(3) +select selectmodule.c # select(2); not on ancient System V # Memory-mapped files (also works on Win32). -#mmap mmapmodule.c +mmap mmapmodule.c # CSV file helper -#_csv _csv.c +_csv _csv.c # Socket module helper for socket(2) -#_socket socketmodule.c +_socket socketmodule.c # Socket module helper for SSL support; you must comment out the other -# socket line above, and possibly edit the SSL variable: -#SSL=/usr/local/ssl -#_ssl _ssl.c \ -# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -# -L$(SSL)/lib -lssl -lcrypto +# socket line above: +_ssl _ssl.c \ + -DUSE_SSL -I/include -I/include/openssl \ + -L/lib -lssl -lcrypto # The crypt module is now disabled by default because it breaks builds # on many systems (where -lcrypt is needed), e.g. Linux (I believe). -#_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems +_crypt _cryptmodule.c -lcrypt # crypt(3); needs -lcrypt on some systems # Some more UNIX dependent modules -- off by default, since these # are not supported by all UNIX systems: #nis nismodule.c -lnsl # Sun yellow pages -- not everywhere -#termios termios.c # Steen Lumholt's termios module +termios termios.c # Steen Lumholt's termios module #resource resource.c # Jeremy Hylton's rlimit interface -#_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper +_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper # Multimedia modules -- off by default. # These don't work for 64-bit platforms!!! @@ -241,18 +241,18 @@ # The _md5 module implements the RSA Data Security, Inc. MD5 # Message-Digest Algorithm, described in RFC 1321. -#_md5 md5module.c +_md5 md5module.c # The _sha module implements the SHA checksum algorithms. # (NIST's Secure Hash Algorithms.) -#_sha1 sha1module.c -#_sha256 sha256module.c -#_sha512 sha512module.c -#_sha3 _sha3/sha3module.c +_sha1 sha1module.c +_sha256 sha256module.c +_sha512 sha512module.c +_sha3 _sha3/sha3module.c # _blake module -#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c +_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c # The _tkinter module. # @@ -305,9 +305,9 @@ # provided by the ncurses library. e.g. on Linux, link with -lncurses # instead of -lcurses). -#_curses _cursesmodule.c -lcurses -ltermcap +_curses _cursesmodule.c -I/include/ncurses -lncurses # Wrapper for the panel library that's part of ncurses and SYSV curses. -#_curses_panel _curses_panel.c -lpanel -lncurses +_curses_panel _curses_panel.c -I/include/ncurses -lpanel -lncurses # Modules that provide persistent dictionary-like semantics. You will @@ -321,25 +321,25 @@ # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: -#_gdbm _gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm +_gdbm _gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm # Helper module for various ascii-encoders -#binascii binascii.c +binascii binascii.c # Fred Drake's interface to the Python parser -#parser parsermodule.c +parser parsermodule.c # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). # See http://www.gzip.org/zlib/ -#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz +zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz # Interface to the Expat XML parser # More information on Expat can be found at www.libexpat.org. # -#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI +pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -L/lib -lexpat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI # Hye-Shik Chang's CJKCodecs