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 <[email protected]>
  • Loading branch information
mr-cal committed Sep 4, 2024
1 parent 0fa19da commit 3508cf3
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 3508cf3

Please sign in to comment.