mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 04:43:45 +03:00
Best-effort attempt at finding libssl (#1167)
This commit is contained in:
parent
1ead9757d3
commit
1dc6d226b7
|
@ -4,12 +4,39 @@ Helper module around the system's libssl library if available for IGE mode.
|
||||||
import ctypes
|
import ctypes
|
||||||
import ctypes.util
|
import ctypes.util
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
__log__ = logging.getLogger(__name__)
|
__log__ = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
lib = ctypes.util.find_library('ssl')
|
lib = ctypes.util.find_library('ssl')
|
||||||
|
|
||||||
|
# This is a best-effort attempt at finding the full real path of lib.
|
||||||
|
#
|
||||||
|
# Unfortunately ctypes doesn't tell us *where* it finds the library,
|
||||||
|
# so we have to do that ourselves.
|
||||||
|
try:
|
||||||
|
# This is not documented, so it could fail. Be on the safe side.
|
||||||
|
import ctypes.macholib.dyld
|
||||||
|
paths = ctypes.macholib.dyld.DEFAULT_LIBRARY_FALLBACK
|
||||||
|
except (ImportError, AttributeError):
|
||||||
|
paths = [
|
||||||
|
os.path.expanduser("~/lib"),
|
||||||
|
"/usr/local/lib",
|
||||||
|
"/lib",
|
||||||
|
"/usr/lib",
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in paths:
|
||||||
|
if os.path.isdir(path):
|
||||||
|
for root, _, files in os.walk(path):
|
||||||
|
if lib in files:
|
||||||
|
# Manually follow symbolic links on *nix systems.
|
||||||
|
# Fix for https://github.com/LonamiWebs/Telethon/issues/1167
|
||||||
|
lib = os.path.realpath(os.path.join(root, lib))
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not lib:
|
if not lib:
|
||||||
raise OSError('no library called "ssl" found')
|
raise OSError('no library called "ssl" found')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user