From 0c183e999ebf4f09f2f1d60dd0ce61ea268a31aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Oct 2024 20:52:27 +1100 Subject: [PATCH] Fix #125958: Disable/uninstall an add-on can keep its dependencies Python wheels from extensions were not being removed after install/uninstall in some cases - although installing an extension afterwards that used wheels would recalculate deps & remove them. - Installing an extension didn't include the extension in the compatibility-cache, causing uninstalling not to remove deps. - Uninstalling an extension wasn't re-calculating the deps, leaving them as-is. Always write the compatibility-cache after installing and uninstalling so changes are detected & handled. --- .../addons_core/bl_pkg/bl_extension_ops.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/scripts/addons_core/bl_pkg/bl_extension_ops.py b/scripts/addons_core/bl_pkg/bl_extension_ops.py index 44b956563d9..20ab7b4a48c 100644 --- a/scripts/addons_core/bl_pkg/bl_extension_ops.py +++ b/scripts/addons_core/bl_pkg/bl_extension_ops.py @@ -1083,13 +1083,20 @@ def _extensions_repo_refresh_on_change(repo_cache_store, *, extensions_enabled, if compat_calc: # NOTE: `extensions_enabled` may contain add-ons which are not yet enabled (these are pending). - # These will *not* have their compatibility information refreshed here. - # This is acceptable because: - # - Installing & enabling an extension relies on the extension being compatible, - # so it can be assumed to already be the compatible. - # - If the add-on existed and was incompatible it *will* have it's compatibility recalculated. - # - Any missing cache entries will cause cache to be re-generated on next start or from an explicit refresh. - addon_utils.extensions_refresh(ensure_wheels=False) + # They *must* have their compatibility information refreshed here, + # even though compatibility is guaranteed based on the code-path that calls this function. + # + # Without updating compatibility information, un-installing the extensions won't detect the + # add-on as having been removed and won't remove any wheels the extension may use, see #125958. + addon_modules_pending = None if extensions_enabled is None else ([ + "{:s}{:s}.{:s}".format(_ext_base_pkg_idname_with_dot, repo_module, pkg_id) + for repo_module, pkg_id in extensions_enabled + ]) + + addon_utils.extensions_refresh( + ensure_wheels=False, + addon_modules_pending=addon_modules_pending, + ) if stats_calc: repo_stats_calc() @@ -3377,7 +3384,7 @@ class EXTENSIONS_OT_package_uninstall(Operator, _ExtCmdMixIn): _extensions_repo_refresh_on_change( repo_cache_store, - extensions_enabled=None, + extensions_enabled=_extensions_enabled(), compat_calc=True, stats_calc=True, )