Workaround for Python 3.11 breaking sys._xoptions

Apparently in Python-land its acceptable behavior to break backward
compatibility with documented interfaces on a whim. Bloody joke.
https://github.com/python/cpython/pull/28823

Fixes #5223
This commit is contained in:
Kovid Goyal
2022-06-23 08:44:34 +05:30
parent 5673359be2
commit f023f047ff
6 changed files with 33 additions and 44 deletions
+3 -2
View File
@@ -305,11 +305,12 @@ def prepend_if_not_present(path: str, paths_serialized: str) -> str:
def ensure_kitty_in_path() -> None:
# Ensure the correct kitty is in PATH
rpath = sys._xoptions.get('bundle_exe_dir')
krd = getattr(sys, 'kitty_run_data')
rpath = krd.get('bundle_exe_dir')
if not rpath:
return
if rpath:
modify_path = is_macos or getattr(sys, 'frozen', False) or sys._xoptions.get('kitty_from_source') == '1'
modify_path = is_macos or getattr(sys, 'frozen', False) or krd.get('from_source')
existing = shutil.which('kitty')
if modify_path or not existing:
env_path = os.environ.get('PATH', '')