diff --git a/picard.spec b/picard.spec index 6e7cbdd57..c69046326 100644 --- a/picard.spec +++ b/picard.spec @@ -67,7 +67,7 @@ if os.path.isfile(ab_extractor_name): runtime_hooks = [] if os_name == 'Windows': - runtime_hooks.append('scripts/pyinstaller/win-console-hook.py') + runtime_hooks.append('scripts/pyinstaller/win-startup-hook.py') elif os_name == 'Darwin': runtime_hooks.append('scripts/pyinstaller/macos-library-path-hook.py') if '--onefile' in sys.argv: diff --git a/scripts/pyinstaller/win-console-hook.py b/scripts/pyinstaller/win-startup-hook.py similarity index 79% rename from scripts/pyinstaller/win-console-hook.py rename to scripts/pyinstaller/win-startup-hook.py index 29e941d54..a704b09d4 100644 --- a/scripts/pyinstaller/win-console-hook.py +++ b/scripts/pyinstaller/win-startup-hook.py @@ -2,7 +2,7 @@ # # Picard, the next-generation MusicBrainz tagger # -# Copyright (C) 2019 Philipp Wolfer +# Copyright (C) 2019, 2021 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -18,7 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - +from ctypes import windll +import os import sys @@ -26,8 +27,9 @@ import sys # to get stdout / stderr logged to console. This needs to happen before # logging gets imported. # See https://stackoverflow.com/questions/54536/win32-gui-app-that-writes-usage-text-to-stdout-when-invoked-as-app-exe-help -if sys.platform == 'win32': - from ctypes import windll - if windll.kernel32.AttachConsole(-1): - sys.stdout = open('CON', 'w') - sys.stderr = open('CON', 'w') +if windll.kernel32.AttachConsole(-1): + sys.stdout = open('CON', 'w') + sys.stderr = open('CON', 'w') + +# Ensure bundled DLLs are loaded +os.environ['PATH'] = sys._MEIPASS + os.pathsep + os.environ['PATH'] \ No newline at end of file diff --git a/tagger.py.in b/tagger.py.in index ceaf22262..91bab7d67 100644 --- a/tagger.py.in +++ b/tagger.py.in @@ -12,9 +12,6 @@ if getattr(sys, 'frozen', False): else: basedir = os.path.dirname(os.path.abspath(__file__)) -if sys.platform == 'win32': - os.environ['PATH'] = basedir + ';' + os.environ['PATH'] - try: from picard.tagger import main main(os.path.join(basedir, 'locale'), %(autoupdate)s)