From 4bbcdddb5b96c08b6bdd5008eafa91d9a6fe00a6 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 2 Apr 2026 16:15:16 +0200 Subject: [PATCH 1/2] Fix library cleanup --- package_control/package_cleanup.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/package_control/package_cleanup.py b/package_control/package_cleanup.py index 7e77f86d..1485956d 100644 --- a/package_control/package_cleanup.py +++ b/package_control/package_cleanup.py @@ -159,20 +159,12 @@ def cleanup_python_environments(self): cache2 = os.path.join(sys_path.cache_path(), "__pycache__", "data", "Lib", "python") supported_versions = sys_path.python_versions() - if "3.3" not in supported_versions: - # Python folder is re-created at each startup, hence just clear it for now. - clear_directory(libdir + "33") - # Python 3.3 itself doesn't support nor create compiled cache modules, - # ST's fallback mechanism might however have created some py38 or py313 cache files - # in those directories, which need to be cleared out. - delete_directory(cache1 + "33") - delete_directory(cache2 + "33") - - if "3.8" not in supported_versions: - # if 3.8 is not supported it is not present, delete all folders - delete_directory(libdir + "38") - delete_directory(cache1 + "38") - delete_directory(cache2 + "38") + for pyver in ("3.3", "3.8", "3.13", "3.14"): + if pyver not in supported_versions: + pyver = pyver.replace(".", "") + clear_directory(libdir + pyver) + delete_directory(cache1 + pyver) + delete_directory(cache2 + pyver) def cleanup_pending_packages(self): """ From 8fece4a89eabc95c16d9b956f926d32266981787 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 2 Apr 2026 18:24:55 +0200 Subject: [PATCH 2/2] Fix supported python version detection This commit uses ST versions to detect supported python version(s), to avoid wrong assumptions if an upgrade doesn't cleanup obsolete files. --- package_control/sys_path.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/package_control/sys_path.py b/package_control/sys_path.py index 3ef5f49a..b057b36e 100644 --- a/package_control/sys_path.py +++ b/package_control/sys_path.py @@ -75,6 +75,8 @@ if __installed_packages_path is None: raise FileNotFoundError('Installed Packages') +assert __data_path + if PREFIX: __data_path = PREFIX + __data_path __default_packages_path = PREFIX + __default_packages_path @@ -151,28 +153,25 @@ def lib_paths(): try: return lib_paths.cache except AttributeError: + assert __data_path st_version = int(sublime.version()) - if st_version > 4000: - root = os.path.dirname(__executable_path) - fext = ".exe" if sublime.platform() == "windows" else "" + if st_version >= 4203: + lib_paths.cache = {"3.14": os.path.join(__data_path, "Lib", "python314")} + elif st_version >= 4201: + lib_paths.cache = {"3.13": os.path.join(__data_path, "Lib", "python313")} + elif st_version >= 4000: + lib_paths.cache = {"3.8": os.path.join(__data_path, "Lib", "python38")} + else: + lib_paths.cache = {"3.3": os.path.join(__data_path, "Lib", "python3.3")} + if st_version >= 4194: settings = sublime.load_settings("Preferences.sublime-settings") - data = ( - ("3.3", "python33", not settings.get('disable_plugin_host_3.3', False)), - ("3.8", "python38", True), - ("3.13", "python313", True), - ("3.14", "python314", True), - ) - lib_paths.cache = { - py_ver: os.path.join(__data_path, "Lib", py_dir) - for py_ver, py_dir, enable in data - if enable and os.path.isfile(os.path.join(root, "plugin_host-" + py_ver + fext)) - } + if not settings.get("disable_plugin_host_3.3", False): + root = os.path.dirname(__executable_path) + fext = ".exe" if sublime.platform() == "windows" else "" + if os.path.isfile(os.path.join(root, "plugin_host-3.3" + fext)): + lib_paths.cache["3.3"] = os.path.join(__data_path, "Lib", "python33") - else: - lib_paths.cache = { - "3.3": os.path.join(__data_path, "Lib", "python3.3") - } return lib_paths.cache