summaryrefslogtreecommitdiffhomepage
path: root/bazarr.py
diff options
context:
space:
mode:
authorAlexander Regueiro <[email protected]>2022-05-08 14:19:38 +0100
committerGitHub <[email protected]>2022-05-08 09:19:38 -0400
commitfcd67c1fb09889c8400751a0d4dabeb264681f0c (patch)
tree562a3438a14d9a27b3a359b370755ff21ef7b824 /bazarr.py
parent3e7186f08088ebb367e133108cdf1f17b3719c74 (diff)
downloadbazarr-fcd67c1fb09889c8400751a0d4dabeb264681f0c.tar.gz
bazarr-fcd67c1fb09889c8400751a0d4dabeb264681f0c.zip
Prevent Python dock icon appearing on macOS
Diffstat (limited to 'bazarr.py')
-rw-r--r--bazarr.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/bazarr.py b/bazarr.py
index a4d248320..b62fc27d8 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -30,6 +30,21 @@ def check_python_version():
sys.exit(1)
+def get_python_path():
+ if sys.platform == "darwin":
+ # Do not run Python from within macOS framework bundle.
+ python_bundle_path = os.path.join(sys.exec_prefix, "Resources", "Python.app", "Contents", "MacOS", "Python")
+ if os.path.exists(python_bundle_path):
+ import tempfile
+
+ python_path = os.path.join(tempfile.mkdtemp(), "python")
+ os.symlink(python_bundle_path, python_path)
+
+ return python_path
+
+ return sys.executable
+
+
check_python_version()
dir_name = os.path.dirname(__file__)
@@ -49,7 +64,7 @@ def terminate_child_process(ep):
def start_bazarr():
- script = [sys.executable, "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:]
+ script = [get_python_path(), "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:]
ep = subprocess.Popen(script, stdout=None, stderr=None, stdin=subprocess.DEVNULL)
atexit.register(end_child_process, ep=ep)
signal.signal(signal.SIGTERM, lambda signal_no, frame: terminate_child_process(ep))