mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix IBM i 'missing libc' failure (#2195)
allow gunicorn on IBM i (and AIX) platform with Python 3.6 and earlier
This commit is contained in:
parent
291483dd39
commit
4d3ec28046
@ -20,10 +20,18 @@ SO_DOMAIN = getattr(socket, 'SO_DOMAIN', 39)
|
|||||||
SO_TYPE = getattr(socket, 'SO_TYPE', 3)
|
SO_TYPE = getattr(socket, 'SO_TYPE', 3)
|
||||||
SO_PROTOCOL = getattr(socket, 'SO_PROTOCOL', 38)
|
SO_PROTOCOL = getattr(socket, 'SO_PROTOCOL', 38)
|
||||||
|
|
||||||
|
|
||||||
_libc_name = find_library('c')
|
_libc_name = find_library('c')
|
||||||
if _libc_name is not None:
|
if _libc_name is not None:
|
||||||
libc = ctypes.CDLL(_libc_name, use_errno=True)
|
if sys.platform.startswith("aix"):
|
||||||
|
member = (
|
||||||
|
'(shr_64.o)' if ctypes.sizeof(ctypes.c_voidp) == 8 else '(shr.o)')
|
||||||
|
# 0x00040000 correspondes to RTLD_MEMBER, undefined in Python <= 3.6
|
||||||
|
dlopen_mode = (ctypes.DEFAULT_MODE | 0x00040000 | os.RTLD_NOW)
|
||||||
|
libc = ctypes.CDLL(_libc_name+member,
|
||||||
|
use_errno=True,
|
||||||
|
mode=dlopen_mode)
|
||||||
|
else:
|
||||||
|
libc = ctypes.CDLL(_libc_name, use_errno=True)
|
||||||
else:
|
else:
|
||||||
raise OSError('libc not found')
|
raise OSError('libc not found')
|
||||||
|
|
||||||
@ -36,6 +44,7 @@ def _errcheck_errno(result, func, arguments):
|
|||||||
raise OSError(errno, os.strerror(errno))
|
raise OSError(errno, os.strerror(errno))
|
||||||
return arguments
|
return arguments
|
||||||
|
|
||||||
|
|
||||||
if platform.system() == 'SunOS':
|
if platform.system() == 'SunOS':
|
||||||
_libc_getsockopt = libc._so_getsockopt
|
_libc_getsockopt = libc._so_getsockopt
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -659,9 +659,9 @@ def _findWalk_ldpath(name):
|
|||||||
if _is_elf(f):
|
if _is_elf(f):
|
||||||
return os.path.basename(f)
|
return os.path.basename(f)
|
||||||
prefix = os.path.join(d, 'lib'+name)
|
prefix = os.path.join(d, 'lib'+name)
|
||||||
for suffix in ['so', 'so.*', '*.so.*']:
|
for suffix in ['so', 'so.*', '*.so.*', 'a']:
|
||||||
for f in glob('{0}.{1}'.format(prefix, suffix)):
|
for f in glob('{0}.{1}'.format(prefix, suffix)):
|
||||||
if _is_elf(f):
|
if _is_elf(f) or suffix == 'a':
|
||||||
return os.path.basename(f)
|
return os.path.basename(f)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user