Skip to content

Commit 8fece4a

Browse files
committed
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.
1 parent 4bbcddd commit 8fece4a

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

package_control/sys_path.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
if __installed_packages_path is None:
7676
raise FileNotFoundError('Installed Packages')
7777

78+
assert __data_path
79+
7880
if PREFIX:
7981
__data_path = PREFIX + __data_path
8082
__default_packages_path = PREFIX + __default_packages_path
@@ -151,28 +153,25 @@ def lib_paths():
151153
try:
152154
return lib_paths.cache
153155
except AttributeError:
156+
assert __data_path
154157
st_version = int(sublime.version())
155-
if st_version > 4000:
156-
root = os.path.dirname(__executable_path)
157-
fext = ".exe" if sublime.platform() == "windows" else ""
158+
if st_version >= 4203:
159+
lib_paths.cache = {"3.14": os.path.join(__data_path, "Lib", "python314")}
160+
elif st_version >= 4201:
161+
lib_paths.cache = {"3.13": os.path.join(__data_path, "Lib", "python313")}
162+
elif st_version >= 4000:
163+
lib_paths.cache = {"3.8": os.path.join(__data_path, "Lib", "python38")}
164+
else:
165+
lib_paths.cache = {"3.3": os.path.join(__data_path, "Lib", "python3.3")}
158166

167+
if st_version >= 4194:
159168
settings = sublime.load_settings("Preferences.sublime-settings")
160-
data = (
161-
("3.3", "python33", not settings.get('disable_plugin_host_3.3', False)),
162-
("3.8", "python38", True),
163-
("3.13", "python313", True),
164-
("3.14", "python314", True),
165-
)
166-
lib_paths.cache = {
167-
py_ver: os.path.join(__data_path, "Lib", py_dir)
168-
for py_ver, py_dir, enable in data
169-
if enable and os.path.isfile(os.path.join(root, "plugin_host-" + py_ver + fext))
170-
}
169+
if not settings.get("disable_plugin_host_3.3", False):
170+
root = os.path.dirname(__executable_path)
171+
fext = ".exe" if sublime.platform() == "windows" else ""
172+
if os.path.isfile(os.path.join(root, "plugin_host-3.3" + fext)):
173+
lib_paths.cache["3.3"] = os.path.join(__data_path, "Lib", "python33")
171174

172-
else:
173-
lib_paths.cache = {
174-
"3.3": os.path.join(__data_path, "Lib", "python3.3")
175-
}
176175
return lib_paths.cache
177176

178177

0 commit comments

Comments
 (0)