From cb8c763ca15a58ac7774dabfedd801e0107fb503 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 6 Nov 2019 11:32:21 +0100 Subject: [PATCH] Move macOS library location fix to pyinstaller hook --- picard.spec | 4 +++- picard/disc.py | 11 ----------- scripts/pyinstaller/macos-library-path-hook.py | 7 +++++++ 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 scripts/pyinstaller/macos-library-path-hook.py diff --git a/picard.spec b/picard.spec index 4af9df32d..8d015e48f 100644 --- a/picard.spec +++ b/picard.spec @@ -76,8 +76,10 @@ if os.path.isfile(fpcalc_name): binaries += [(fpcalc_name, '.')] runtime_hooks = [] -if sys.platform == 'win32': +if os_name == 'Windows': runtime_hooks.append('scripts/pyinstaller/win-console-hook.py') +elif os_name == 'Darwin': + runtime_hooks.append('scripts/pyinstaller/macos-library-path-hook.py') if '--onefile' in sys.argv: runtime_hooks.append('scripts/pyinstaller/portable-hook.py') diff --git a/picard/disc.py b/picard/disc.py index cf49f3441..e409ecebd 100644 --- a/picard/disc.py +++ b/picard/disc.py @@ -20,26 +20,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -import os -import sys import traceback from PyQt5 import QtCore from picard import log -from picard.const.sys import ( - IS_FROZEN, - IS_MACOS, -) from picard.ui.cdlookup import CDLookupDialog -# Ensure libdiscid.dylib gets loaded from app bundle -if IS_MACOS and IS_FROZEN: - os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = '%s:%s' % ( - os.path.dirname(sys.executable), os.environ.get('DYLD_FALLBACK_LIBRARY_PATH', '')) - try: # use python-libdiscid (http://pythonhosted.org/python-libdiscid/) from libdiscid.compat import discid diff --git a/scripts/pyinstaller/macos-library-path-hook.py b/scripts/pyinstaller/macos-library-path-hook.py new file mode 100644 index 000000000..31bb76215 --- /dev/null +++ b/scripts/pyinstaller/macos-library-path-hook.py @@ -0,0 +1,7 @@ +import os +import sys + + +# On macOS ensure libraries such as libdiscid.dylib get loaded from app bundle +os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = '%s:%s' % ( + os.path.dirname(sys.executable), os.environ.get('DYLD_FALLBACK_LIBRARY_PATH', ''))