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

Update Package Control to 4.0 #1658

Merged
merged 650 commits into from
Dec 2, 2023
Merged

Update Package Control to 4.0 #1658

merged 650 commits into from
Dec 2, 2023

Conversation

deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented Dec 2, 2023

No description provided.

The method now takes a list of actions to return packages for, which is
easier to follow than the black list used before.
Fixes #1272

Upgrading packages should never convert unmanaged into managed packages.
Conversion is to be done via "Install Package" command only.
git/hg commands are executed for each tracked package, resulting in
undetermined amount of error dialogs if something goes wrong.

To avoid error message flooding, errors are printed to console only.
ST no longer needs to be restarted after changing ignore_vcs_packages.
The try catch approach results in exceptions telling _tracker.cache not
being available, in rare situations, if python 3.8 plugins are updated.
Reason still unclear, but maybe the global __tracker object helps.
Fixes an invalid operator which prevents missing and renamed packages
from being installed or the `installed_packages` setting from being
cleaned up.
Caused by 6a3b4b1

As settings are no longer saved to disk for each installed or removed
package individually, it must be done once after everything is done.

Otherwise removing disabled packages results in them being re-installed
as missing at next startup.
Hide Package Control from Disable Package quick panels.
The `imp` module is deprecated in python 3.8
Satisfy linter which complained about `machinery` not being a valid
member of `importlib`.
This commit removes freshly installed or removed packages from
`ignored_packages` once operation has finished in order to

a) don't leave zombie entries behind after a package has been removed
b) to ensure an installed package starts working immediately
Query active window directly in `__init__()`.
Fixes #1370

This commit makes renaming packages an integral part of upgrading.

Relational
----------

Packages have been disabled, renamed and re-enabled, before they have
been disabled again for being updated.

AutomaticUpgrader even renamed packages which were excluded from updates
via `auto_upgrade_ignore` setting.

Re-enabling a renamed but not (yet) updated package may cause it to
raise exceptions during reloading because of broken resource links.

1. Hence error messages in console during a normal package update are
   very likely.
2. Enabling and then immediately disabling a package is wasted time and
   may cause avoidable problems, especially for more sophisticated
   plugins, for which reloading is expensive.
3. If the update process fails, the old but renamed package will fail to
   load forever.

It is therefore crucial to make sure a package is renamed only, if it
is for sure to be updated.
This commit refactors how package installs and updates are scheduled
and performed.

Basic concept is to create `PackageTask` objects with all required
information to display quick panel items and perform installation or
upgrade.

`PackageInstaller` is renamed to `PackageTaskRunner` to express its
probably more general scope.

The `PackageInstaller.make_package_list()` is therefore split into two
methods:

- `create_package_tasks` creates task objects.
- `render_quick_panel_items` creates quick panel items for tasks.

The methods `run_install_tasks` and `run_upgrade_tasks` run specified
tasks.

The major motivations are:

1. The requirement to disable both old and new name of renamed packages.
   That's a follow up of previous commit.

2. Create a list of tasks, which already contains all required
   information to perform installs and/or updates, so that they don't
   need to be queried again in `PackageManager.install_package()`.

3. Split front-end code for rendering quick panel items, from business
   logic. This is required to establish new ST4 only front-end features
   such as quick panel icons without polluting the whole code base.

4. Use `install_packages` and `upgrade_packages` methods for all manual
   or automatic operations in order to reduce code duplication.

A nice benefit is quick panels showing up 3x faster than before.

Time needed to schedule tasks and render quick panel items dropped from
about 300ms to 100ms for Install Packages command and 300ms to 50ms for
Update Packages command once the download cache is warmed up.
Drop separate Thread classes, which are also PackageInstallers.

Use closure functions instead, to handle life cycle of required objects
to comply with Python's "as local as possible" style guide.

It also seems a bit odd to create a `Thread` for a task, while running
subsequent async operations via `threading.Thread(target=...)`.

The goal is to run async tasks in a thread pool using a global
`ThreadPoolExecutor` object in the future.
This commit trims leading `v` from version strings.
This commit adds support for 3rd-party packages overriding built-in packages.

1. Packages located in 'Data/Installed Packages' or 'Data/Packages', whose name
   match a built-in package, are no longer ignored, but treated as normally
   installed by all means.

2. A "Revert Package" command is added to explicitly list and uninstall
   built-in package overrides. It performs a normal "remove_package" operation.
   They are not listed in "Remove Package" quick panel to avoid confusion.
Replace `--ff --commit` by `--ff-only`.
Add `--quiet` as output is not displayed anywhere.
This commit enforces any package named "Default" to be installed as unpacked
package, so only individual files from are overridden. Otherwise things could
badly break.

This enables repos like https://github.com/deathaxe/sublime-commands 
to be safely installed as 3rd-party "Default" package via Package Control,
even if they wouldn't contain a `.no-sublime-package` file.
Avoid exceptions if base path no longer exists.
Some tests used single- other double-qouted strings. Now all use the latter.
This commit creates a global constant to point to "package_control-json" URL.

1. shorter strings in test cases
2. easier replacement in case test data is to be downloaded from different URL.
When running on Github Actions runner, use /home/worker/sublime_text as scratch
directory for testing.

Reason:

A deterministic path is needed in case of http_cache is to be stored
This commit...

1. moves BitBucket test classes.
2. adds missing @data_decorator annotation to BitBucketClientTests
Python 3.3 raises an exception at `reversed(dict.items())` as `items()` are not
treated as Sequence. Additionally dictionary keys' order is undefined.

Therefore release keys (versions) are sorted and enumerated separately.
Dependencies are installed as python libraries, which causes ST package style
dependency information to get lost. As a result subsequent calls to
"satisfy libraries" wouldn't be able to restore required dependency information
and thus remove those libraries again.

As PC3.x didn't support ST dependencies with dependencies, it's most safe to
restore that state for the time being as converting them to "requirements.txt"
may be cumbersome and likely to fail as they can't be distinguished from normal
python packages then.

On the other hand maintaining 3 independent dependency systems for packages,
legacy dependencies and python packages is probably not worth it.

2 are enough for a future plan.
This commit finally adds support for checking download's sha256 hash against
an optional value given in repository.json

Package Control claimed to require a sha256 for HTTP downloads, but actually
didn't check it.
Fixes #1418

This commit sends removed packages to "Trash", if their file is still locked
by Windows OS. That's most likely caused by external processes interacting with
that file, which may be anti-virus programs or Sublime Merge holding a lock due
to using the package. Renaming triggers unloading and thus frees the lock.
Trash is cleared at next ST startup.

That's basically the same strategy used to remove libraries.
One of the steps to help fixing various kinds of issues is to ask users to
delete the "$DATA/Cache" directory. This commit adds a command to simplify that
step.
Not ideal, but the only way to support migration to python 3.8 for all packages
is to provide an intermediate channel_v4 with required metadata to support
already existing dependencies/libraries on python 3.8 plugin_host.

Note: They are maintained at https://github.com/packagecontrol/channel
@deathaxe deathaxe merged commit 284df2c into master Dec 2, 2023
12 checks passed
@deathaxe deathaxe deleted the four-point-oh branch December 2, 2023 15:29
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.

6 participants