From 5977d7e7fd87972ac5845f7b537971bc58ff7cd1 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 30 May 2025 02:01:14 +0200 Subject: [PATCH] Install further packages automatically PC has the notion of "dependent" or additional packages. These are defined in a standard "Package Control.sublime-settings" file, hosted by the package. (I.e. similar to the "dependencies.json".) Installing such a package did not install the additional packages in one go, neither did it notify about the incomplete install. In the end, a restart is enough and required to trigger `install_missing_packages()` to catch up and install everything. We have two options here. (1) to bail out `install_package` with `return None` and a message to tell the user to restart Sublime, or (2) to install the packages in a recursive style. Here we choose (1) which is a simple babystep for a better UX. (2) is not possible as all install side-effects need to run serialized. --- package_control/package_manager.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/package_control/package_manager.py b/package_control/package_manager.py index dc43c27e..00ee8c35 100644 --- a/package_control/package_manager.py +++ b/package_control/package_manager.py @@ -1600,6 +1600,33 @@ def install_package(self, package_name, unattended=False): fail_early=False ) + try: + extra_pc_settings_json = package_zip.read(common_folder + 'Package Control.sublime-settings') + extra_pc_settings = json.loads(extra_pc_settings_json.decode('utf-8')) + except (KeyError): + pass + except (ValueError): + console_write( + ''' + Failed to parse the Package Control.sublime-settings for "%s" + ''', + package_name + ) + else: + wanted_packages = set(extra_pc_settings.get('installed_packages') or []) + pc_settings = sublime.load_settings(pc_settings_filename()) + in_process_packages = load_list_setting(pc_settings, 'in_process_packages') + additional_packages = wanted_packages - in_process_packages - self.installed_packages() + if additional_packages: + console_write( + ''' + Failed to install %s - + deferring until next start to install additional packages + ''', + package_name + ) + return None + if package_name != old_package_name: self.rename_package(old_package_name, package_name)