From 5e66e81ab7ef5c15be162575ff261f0891fb3de3 Mon Sep 17 00:00:00 2001 From: Maran Date: Mon, 17 Jun 2013 00:25:03 +0200 Subject: [PATCH] Make sure libcrypto from brew is linked. In the resulting .app --- osx.sh | 1 + src/build_osx.py | 11 ++++++++++- src/pyelliptic/openssl.py | 30 +++++++++++++++++------------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/osx.sh b/osx.sh index ca05ffde..e5d2e371 100755 --- a/osx.sh +++ b/osx.sh @@ -3,6 +3,7 @@ # OS X Build script wrapper around the py2app script. # These build can only be generated on OS X. # Requires all build dependencies for Bitmessage +# Especially important is openssl installed through brew export ARCHFLAGS="-arch i386 -arch x86_64" diff --git a/src/build_osx.py b/src/build_osx.py index ded1be4a..de08da4c 100644 --- a/src/build_osx.py +++ b/src/build_osx.py @@ -21,8 +21,9 @@ if sys.platform == 'darwin': setup_requires=['py2app'], app=[mainscript], options=dict(py2app=dict(argv_emulation=True, - includes = ['PyQt4.QtCore','PyQt4.QtGui', 'sip', 'sqlite'], + includes = ['PyQt4.QtCore','PyQt4.QtGui', 'sip'], packages = ['bitmessageqt'], + frameworks = ['/usr/local/opt/openssl/lib/libcrypto.dylib'], iconfile='images/bitmessage.icns', resources=["images"])), ) @@ -44,9 +45,17 @@ setup( **extra_options ) from distutils import dir_util +import glob if sys.platform == 'darwin': resource = "dist/" + name + ".app/Contents/Resources/" + framework = "dist/" + name + ".app/Contents/Frameworks/" + + # The pyElliptive module only works with hardcoded libcrypto paths so rename it so it can actually find it. + libs = glob.glob(framework + "libcrypto*.dylib") + for lib in libs: + os.rename(lib, framework + "libcrypto.dylib") + break # Try to locate qt_menu # Let's try the port version first! diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index 59a0d324..de073fab 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -419,17 +419,21 @@ except: OpenSSL = _OpenSSL('/usr/local/opt/openssl/lib/libcrypto.dylib') except: try: - from os import path - lib_path = path.join(sys._MEIPASS, "libeay32.dll") - OpenSSL = _OpenSSL(lib_path) + # Load it from an Bitmessage.app on OSX + OpenSSL = _OpenSSL('./../Frameworks/libcrypto.dylib') except: - if 'linux' in sys.platform or 'darwin' 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.") + 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: + 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.")