Skip to content

Commit

Permalink
refactor: enable craft-parts features in the correct location
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
  • Loading branch information
mr-cal committed Sep 3, 2024
1 parent 3cb2e1f commit 48d8d63
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions snapcraft/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 48d8d63

Please sign in to comment.