Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path detection algorithm #1681

Merged
merged 1 commit into from
Jun 2, 2024
Merged

Fix path detection algorithm #1681

merged 1 commit into from
Jun 2, 2024

Conversation

deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented Jun 2, 2024

Fix path detection algorithm

This commit uses a more robust algorithm to determine ST paths at startup,
which no longer relies on Default.sort module.

It fixes an issue, which caused {st_dir}/Packages path detection to fail, if
Default package is extracted to {data}/Packages by end users.

To determine default package path, it first tries sublime.executable_path(),
which returns valid paths at import time on ST4088+ or with mocked ST API
in CI environments. When running on ST3, abspath(sys.executable) is used
instead to return plugin_host's absolute path. Without it, sys.executable
only returns "python" on ST3's plugin_host.

This commit ...

1. uses a more robust algorithm to determine special ST paths at startup, which
   no longer relies on location of `Default.sort` module, but uses
   `sys.executable` variable to determine, whether PC is running within
   ST plugin environment or on an external CI runner which mocks ST API.

   The new approach fixes an issue, which causes path detection to resolve
   invalid paths, if users extract whole Default package.
   PC assumed sublimehq's development environment in that case.

2. moves forward to rely on `__spec__` in favor of `__file__` and `__loader__`
   as this is what python is moving to in general. The ladder ones are dropped
   step by step by recent python releases (3.13).
@deathaxe deathaxe force-pushed the fix/package-path-detection branch from e88cc41 to 737bb48 Compare June 2, 2024 11:47
@deathaxe deathaxe merged commit 6cce073 into master Jun 2, 2024
8 checks passed
@deathaxe deathaxe deleted the fix/package-path-detection branch June 2, 2024 12:11
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.

1 participant