Skip to content

Conversation

@deathaxe
Copy link
Contributor

No description provided.

@deathaxe deathaxe force-pushed the feat/python313 branch 5 times, most recently from 67a80c3 to 2343a35 Compare August 2, 2025 09:34
This commit fixes an issue with compiled python module path detection.

Location differs depending on portable or non-portable ST builds, which
hasn't been taken into account up to this commit. Hence module caches
haven't been deleted when uninstalling libraries or packages in non-portable
setups, before.
This commit dynamically evaluates supported python environments,
depending on `disable_plugin_host_3.3` setting and existing plugin_host
executables to return correct paths regardless ST versions.

It should help reducing maintenance burden with upcoming transitions:

   3.3/3.8 => 3.3/3.13 => 3.13
if a legacy dependency doesn't contain `st4_py313` folder, fallback to
`st4_py38` or `st4` folders for implicit wheel conversion.

It ensures existing dependencies, such as lsp_utils to continue working
as good as possible, assuming no code-specific incompatibilities exist.

It continues existing fallback strategies, also available for py38->py33.
This commit adjusts the algorithm to detect which plugin_host a plugin runs on.

The following cases are covered.

ST3143 .. 3211:
  - only py33

ST4000 .. 4192:
  - plugin in "User" package => py38
  - .python-version present and contains "38" => py38
  - otherwise => py33

ST4193 .. 4200:
  - plugin in "User" package => py38
  - disable_plugin_host_3.3 = True => py38
  - .python-version present and contains "38" => py38
  - otherwise => py33

ST4201 .. 42??:
  - plugin in "User" package => py313
  - disable_plugin_host_3.3 = True => py313
  - .python-version present => py313
  - otherwise => py33

ST42??+
  - only py313
This commit satisfies required libraries after all packages have been installed,
instead of resolving and installing each required library before a package is.

Advantages:

1. not yet installed package source doesn't need to be scanned for required
   libraries or the plugin host it will run on. Reduces code duplication.
2. package and library installation/upgrade can be parallelized in a future
   version, without risk to install a library twice due to race conditions.
3. separation of concerns; low-level `install_package()` function just installs
   a package and `install_library()` just a library.
Python 3.1x moves on to replace __file__ and __package__ entirely by __spec__.
This commit ensures to keep up and avoid issues with former 2 being no longer
maintained or even removed at some point in future.
This commit creates dedicated asset templates for value of "python_version"
key to make sure PyPiClient downloads latest available package for each
python version.

The issue to solve is that pure python packages don't carry any information
about supported python versions in their name.

   name-1.0.0-py3-any.whl   maybe 3.8+
   name-1.1.0-py3-any.whl   maybe 3.13+
This commit explicitly sets `__name__` and `__package__` in plugin.py as those
are heavily used despite probably no longer being initialized on python 3.13,
if Package Control is loaded from .sublime-package.
1. ensure python 3.13 compatibility with regards to `__file__` vs. `__spec__`
2. ensure module produces same behavior on all available plugin_hosts
3. remove writing `__spec__` as it has no effect. Final value always contains
   information from original injector module.
4. as no sublime API is required, install injector module at import time
   so it is eventually available earlier.
5. ensure injector module is also re-installed in cases, the original one
   causes import errors in package_disabler module, auto-repair so to say.
@deathaxe deathaxe merged commit 4b1a80d into master Aug 4, 2025
0 of 8 checks passed
@deathaxe deathaxe deleted the feat/python313 branch August 4, 2025 09:40
@rwols
Copy link
Contributor

rwols commented Nov 11, 2025

How is this distributed? I'm currently seeing errors about a non-existant python3.13 directory.

Exception in thread Thread-7:
Traceback (most recent call last):
  File "./python3.13/threading.py", line 1043, in _bootstrap_inner
  File "/home/raoul/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_cleanup.py", line 108, in run
    self.manager.cleanup_libraries()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/raoul/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 1384, in cleanup_libraries
    orphaned_libraries = self.find_orphaned_libraries(required_libraries)
  File "/home/raoul/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 982, in find_orphaned_libraries
    installed_libraries = self.list_libraries()
  File "/home/raoul/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 785, in list_libraries
    return library.list_all()
           ~~~~~~~~~~~~~~~~^^
  File "/home/raoul/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/library.py", line 165, in list_all
    for fname in os.listdir(install_root):
                 ~~~~~~~~~~^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/raoul/.config/sublime-text-3/Lib/python3.13'

@deathaxe
Copy link
Contributor Author

deathaxe commented Nov 11, 2025

This PR is already part of v4.2.2

PR #1713 adjusts the expected library folder name.

All open PRs however require action by the original author and repo owner to be released via known update channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants