Skip to content

Commit bea2c58

Browse files
authored
Fix order of supported python versions (#1740)
This commit fixes `sys_path.python_versions()` returning supported plugin hosts in wrong order, causing libraries being installed for wrong hosts.
1 parent f038dd2 commit bea2c58

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

package_control/sys_path.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def lib_paths():
147147
"""
148148
Returns a dict of version-specific lib folders
149149
150+
CAUTION:
151+
Keys must be ordered by PEP440 for `python_versions()` function!
152+
Hence oder of adding items to dict is important!
153+
150154
:return:
151155
A dict with the key "3.3" and possibly the key "3.8"
152156
"""
@@ -155,25 +159,27 @@ def lib_paths():
155159
except AttributeError:
156160
assert __data_path
157161
st_version = int(sublime.version())
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")}
162+
if st_version >= 4000:
163+
# register plugin_host-3.3
164+
have_py33 = st_version < 4193
165+
if not have_py33:
166+
settings = sublime.load_settings("Preferences.sublime-settings")
167+
have_py33 = not settings.get("disable_plugin_host_3.3", False)
168+
if have_py33:
169+
root = os.path.dirname(__executable_path)
170+
fext = ".exe" if sublime.platform() == "windows" else ""
171+
have_py33 = os.path.isfile(os.path.join(root, "plugin_host-3.3" + fext))
172+
lib_paths.cache = {"3.3": os.path.join(__data_path, "Lib", "python33")} if have_py33 else {}
173+
# register plugin_host-3.xx
174+
if st_version >= 4203:
175+
lib_paths.cache["3.14"] = os.path.join(__data_path, "Lib", "python314")
176+
elif st_version >= 4201:
177+
lib_paths.cache["3.13"] = os.path.join(__data_path, "Lib", "python313")
178+
elif st_version >= 4000:
179+
lib_paths.cache["3.8"] = os.path.join(__data_path, "Lib", "python38")
164180
else:
165181
lib_paths.cache = {"3.3": os.path.join(__data_path, "Lib", "python3.3")}
166182

167-
if st_version >= 4194:
168-
settings = sublime.load_settings("Preferences.sublime-settings")
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")
174-
elif st_version >= 4000:
175-
lib_paths.cache["3.3"] = os.path.join(__data_path, "Lib", "python33")
176-
177183
return lib_paths.cache
178184

179185

0 commit comments

Comments
 (0)