Skip to content

Commit 5977d7e

Browse files
committed
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.
1 parent 904eb36 commit 5977d7e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

package_control/package_manager.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,33 @@ def install_package(self, package_name, unattended=False):
16001600
fail_early=False
16011601
)
16021602

1603+
try:
1604+
extra_pc_settings_json = package_zip.read(common_folder + 'Package Control.sublime-settings')
1605+
extra_pc_settings = json.loads(extra_pc_settings_json.decode('utf-8'))
1606+
except (KeyError):
1607+
pass
1608+
except (ValueError):
1609+
console_write(
1610+
'''
1611+
Failed to parse the Package Control.sublime-settings for "%s"
1612+
''',
1613+
package_name
1614+
)
1615+
else:
1616+
wanted_packages = set(extra_pc_settings.get('installed_packages') or [])
1617+
pc_settings = sublime.load_settings(pc_settings_filename())
1618+
in_process_packages = load_list_setting(pc_settings, 'in_process_packages')
1619+
additional_packages = wanted_packages - in_process_packages - self.installed_packages()
1620+
if additional_packages:
1621+
console_write(
1622+
'''
1623+
Failed to install %s -
1624+
deferring until next start to install additional packages
1625+
''',
1626+
package_name
1627+
)
1628+
return None
1629+
16031630
if package_name != old_package_name:
16041631
self.rename_package(old_package_name, package_name)
16051632

0 commit comments

Comments
 (0)