From 440344166756d78af2f32b033f3757d758ac4926 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Tue, 3 Sep 2024 09:11:15 -0500 Subject: [PATCH] refactor: enable craft-parts features in the correct location Signed-off-by: Callahan Kovacs --- snapcraft/application.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/snapcraft/application.py b/snapcraft/application.py index e842fecb74..b26749d264 100644 --- a/snapcraft/application.py +++ b/snapcraft/application.py @@ -233,20 +233,18 @@ def run(self) -> int: return return_code + @override + def _enable_craft_parts_features(self) -> None: + """Enable partitions if components are defined.""" + if self._snapcraft_yaml_data and self._snapcraft_yaml_data.get("components"): + craft_parts.Features(enable_partitions=True) + @override def _setup_partitions(self, yaml_data: dict[str, Any]) -> list[str] | None: components = models.ComponentProject.unmarshal(yaml_data) if components.components is None: return None - # Users of partitions need to manually enable them, in Snapcraft - # this is done dynamically depending on the existence of components. - # This is why we have the enablement after the check, if not - # we could have directly returned with .get_partitions() which - # handles the empty case. - craft_parts.Features.reset() - craft_parts.Features(enable_partitions=True) - return components.get_partitions() @override