Improve OpenSSL library finder
This commit is contained in:
parent
b7e24fab4a
commit
dc34c00f38
|
@ -427,35 +427,44 @@ class _OpenSSL:
|
||||||
buffer = self.create_string_buffer(size)
|
buffer = self.create_string_buffer(size)
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
try:
|
def loadOpenSSL():
|
||||||
OpenSSL = _OpenSSL('libcrypto.so')
|
global OpenSSL
|
||||||
except:
|
from os import path, environ
|
||||||
try:
|
from ctypes.util import find_library
|
||||||
OpenSSL = _OpenSSL('libeay32.dll')
|
|
||||||
except:
|
libdir = []
|
||||||
|
if getattr(sys,'frozen', None):
|
||||||
|
if 'darwin' in sys.platform:
|
||||||
|
libdir.extend([
|
||||||
|
path.join(environ['RESOURCEPATH'], '..', 'Frameworks','libcrypto.dylib'),
|
||||||
|
path.join(environ['RESOURCEPATH'], '..', 'Frameworks','libcrypto.1.0.0.dylib')
|
||||||
|
])
|
||||||
|
elif 'win32' in sys.platform or win64:
|
||||||
|
lib.append(path.join(sys._MEIPASS, 'libeay32.dll'))
|
||||||
|
else:
|
||||||
|
libdir.extend([
|
||||||
|
path.join(sys._MEIPASS, 'libcrypto.so'),
|
||||||
|
path.join(sys._MEIPASS, 'libssl.so'),
|
||||||
|
path.join(sys._MEIPASS, 'libcrypto.so.1.0.0'),
|
||||||
|
path.join(sys._MEIPASS, 'libssl.so.1.0.0'),
|
||||||
|
])
|
||||||
|
if 'darwin' in sys.platform:
|
||||||
|
libdir.extend(['libcrypto.dylib', '/usr/local/opt/openssl/lib/libcrypto.dylib'])
|
||||||
|
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
|
libdir.append('libeay32.dll')
|
||||||
|
else:
|
||||||
|
libdir.append('libcrypto.so')
|
||||||
|
libdir.append('libssl.so')
|
||||||
|
if 'linux' in sys.platform or 'darwin' in sys.platform or 'freebsd' in sys.platform:
|
||||||
|
libdir.append(find_library('ssl'))
|
||||||
|
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
|
libdir.append(find_library('libeay32'))
|
||||||
|
for library in libdir:
|
||||||
try:
|
try:
|
||||||
OpenSSL = _OpenSSL('libcrypto.dylib')
|
OpenSSL = _OpenSSL(library)
|
||||||
|
return
|
||||||
except:
|
except:
|
||||||
try:
|
pass
|
||||||
# try homebrew installation
|
raise Exception("Couldn't find and load the OpenSSL library. You must install it.")
|
||||||
OpenSSL = _OpenSSL('/usr/local/opt/openssl/lib/libcrypto.dylib')
|
|
||||||
except:
|
loadOpenSSL()
|
||||||
try:
|
|
||||||
# Load it from an Bitmessage.app on OSX
|
|
||||||
OpenSSL = _OpenSSL('./../Frameworks/libcrypto.dylib')
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
from os import path
|
|
||||||
lib_path = path.join(sys._MEIPASS, "libeay32.dll")
|
|
||||||
OpenSSL = _OpenSSL(lib_path)
|
|
||||||
except:
|
|
||||||
if 'linux' in sys.platform or 'darwin' in sys.platform or 'freebsd' in sys.platform:
|
|
||||||
try:
|
|
||||||
from ctypes.util import find_library
|
|
||||||
OpenSSL = _OpenSSL(find_library('ssl'))
|
|
||||||
except Exception, err:
|
|
||||||
sys.stderr.write('(On Linux) Couldn\'t find and load the OpenSSL library. You must install it. If you believe that you already have it installed, this exception information might be of use:\n')
|
|
||||||
from ctypes.util import find_library
|
|
||||||
OpenSSL = _OpenSSL(find_library('ssl'))
|
|
||||||
else:
|
|
||||||
raise Exception("Couldn't find and load the OpenSSL library. You must install it.")
|
|
Loading…
Reference in New Issue
Block a user