at master 4.3 kB view raw
1From 6b0f329a9f37110020ca02b35c8125391ef282b7 Mon Sep 17 00:00:00 2001 2From: Frederik Rietdijk <fridh@fridh.nl> 3Date: Sat, 24 Dec 2016 15:56:10 +0100 4Subject: [PATCH] no ldconfig 5 6--- 7 Lib/ctypes/util.py | 35 +---------------------------------- 8 Lib/uuid.py | 47 ----------------------------------------------- 9 2 files changed, 1 insertion(+), 81 deletions(-) 10 11diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py 12index ab10ec5..f253e34 100644 13--- a/Lib/ctypes/util.py 14+++ b/Lib/ctypes/util.py 15@@ -235,40 +235,7 @@ elif os.name == "posix": 16 else: 17 18 def _findSoname_ldconfig(name): 19- import struct 20- if struct.calcsize('l') == 4: 21- machine = os.uname()[4] + '-32' 22- else: 23- machine = os.uname()[4] + '-64' 24- mach_map = { 25- 'x86_64-64': 'libc6,x86-64', 26- 'ppc64-64': 'libc6,64bit', 27- 'sparc64-64': 'libc6,64bit', 28- 's390x-64': 'libc6,64bit', 29- 'ia64-64': 'libc6,IA-64', 30- } 31- abi_type = mach_map.get(machine, 'libc6') 32- 33- # XXX assuming GLIBC's ldconfig (with option -p) 34- expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type) 35- 36- env = dict(os.environ) 37- env['LC_ALL'] = 'C' 38- env['LANG'] = 'C' 39- null = open(os.devnull, 'wb') 40- try: 41- with null: 42- p = subprocess.Popen(['/sbin/ldconfig', '-p'], 43- stderr=null, 44- stdout=subprocess.PIPE, 45- env=env) 46- except OSError: # E.g. command not found 47- return None 48- [data, _] = p.communicate() 49- res = re.search(expr, data) 50- if not res: 51- return None 52- return res.group(1) 53+ return None 54 55 def find_library(name): 56 return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) 57diff --git a/Lib/uuid.py b/Lib/uuid.py 58index 7432032..05eeee5 100644 59--- a/Lib/uuid.py 60+++ b/Lib/uuid.py 61@@ -441,53 +441,6 @@ def _netbios_getnode(): 62 63 # If ctypes is available, use it to find system routines for UUID generation. 64 _uuid_generate_time = _UuidCreate = None 65-try: 66- import ctypes, ctypes.util 67- import sys 68- 69- # The uuid_generate_* routines are provided by libuuid on at least 70- # Linux and FreeBSD, and provided by libc on Mac OS X. 71- _libnames = ['uuid'] 72- if not sys.platform.startswith('win'): 73- _libnames.append('c') 74- for libname in _libnames: 75- try: 76- lib = ctypes.CDLL(ctypes.util.find_library(libname)) 77- except: 78- continue 79- if hasattr(lib, 'uuid_generate_time'): 80- _uuid_generate_time = lib.uuid_generate_time 81- break 82- del _libnames 83- 84- # The uuid_generate_* functions are broken on MacOS X 10.5, as noted 85- # in issue #8621 the function generates the same sequence of values 86- # in the parent process and all children created using fork (unless 87- # those children use exec as well). 88- # 89- # Assume that the uuid_generate functions are broken from 10.5 onward, 90- # the test can be adjusted when a later version is fixed. 91- if sys.platform == 'darwin': 92- import os 93- if int(os.uname()[2].split('.')[0]) >= 9: 94- _uuid_generate_time = None 95- 96- # On Windows prior to 2000, UuidCreate gives a UUID containing the 97- # hardware address. On Windows 2000 and later, UuidCreate makes a 98- # random UUID and UuidCreateSequential gives a UUID containing the 99- # hardware address. These routines are provided by the RPC runtime. 100- # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the last 101- # 6 bytes returned by UuidCreateSequential are fixed, they don't appear 102- # to bear any relationship to the MAC address of any network device 103- # on the box. 104- try: 105- lib = ctypes.windll.rpcrt4 106- except: 107- lib = None 108- _UuidCreate = getattr(lib, 'UuidCreateSequential', 109- getattr(lib, 'UuidCreate', None)) 110-except: 111- pass 112 113 def _unixdll_getnode(): 114 """Get the hardware address on Unix using ctypes.""" 115-- 1162.11.0 117