diff --git a/snapcraft/extensions/_ros2_humble_meta.py b/snapcraft/extensions/_ros2_humble_meta.py index be3d3ecff8..3d23330d71 100644 --- a/snapcraft/extensions/_ros2_humble_meta.py +++ b/snapcraft/extensions/_ros2_humble_meta.py @@ -64,8 +64,8 @@ def get_root_snippet(self) -> Dict[str, Any]: return root_snippet @overrides - def get_app_snippet(self) -> Dict[str, Any]: - app_snippet = super().get_app_snippet() + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: + app_snippet = super().get_app_snippet(app_name=app_name) python_paths = app_snippet["environment"]["PYTHONPATH"] new_python_paths = [ f"$SNAP/opt/ros/underlay_ws/opt/ros/{self.ROS_DISTRO}/lib/python3.10/site-packages", diff --git a/snapcraft/extensions/_ros2_jazzy_meta.py b/snapcraft/extensions/_ros2_jazzy_meta.py index 9dcf31ad0d..b230119661 100644 --- a/snapcraft/extensions/_ros2_jazzy_meta.py +++ b/snapcraft/extensions/_ros2_jazzy_meta.py @@ -64,8 +64,8 @@ def get_root_snippet(self) -> Dict[str, Any]: return root_snippet @overrides - def get_app_snippet(self) -> Dict[str, Any]: - app_snippet = super().get_app_snippet() + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: + app_snippet = super().get_app_snippet(app_name=app_name) python_paths = app_snippet["environment"]["PYTHONPATH"] new_python_paths = [ f"$SNAP/opt/ros/underlay_ws/opt/ros/{self.ROS_DISTRO}/lib/python3.12/site-packages", diff --git a/snapcraft/extensions/_utils.py b/snapcraft/extensions/_utils.py index 3aa885be35..d382ca44db 100644 --- a/snapcraft/extensions/_utils.py +++ b/snapcraft/extensions/_utils.py @@ -79,8 +79,8 @@ def _apply_extension( ) # Apply the app-specific components of the extension (if any) - app_extension = extension.get_app_snippet() for app_name in app_names: + app_extension = extension.get_app_snippet(app_name=app_name) app_definition = yaml_data["apps"][app_name] for property_name, property_value in app_extension.items(): app_definition[property_name] = _apply_extension_property( diff --git a/snapcraft/extensions/extension.py b/snapcraft/extensions/extension.py index 52cdfd902e..bf3c4bb04d 100644 --- a/snapcraft/extensions/extension.py +++ b/snapcraft/extensions/extension.py @@ -66,8 +66,11 @@ def get_root_snippet(self) -> Dict[str, Any]: """Return the root snippet to apply.""" @abc.abstractmethod - def get_app_snippet(self) -> Dict[str, Any]: - """Return the app snippet to apply.""" + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: + """Return the app snippet to apply. + + :param app_name: the name of the app where the snippet will be applied + """ @abc.abstractmethod def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: diff --git a/snapcraft/extensions/gnome.py b/snapcraft/extensions/gnome.py index 30e7eeeb23..0f0c3be7ab 100644 --- a/snapcraft/extensions/gnome.py +++ b/snapcraft/extensions/gnome.py @@ -85,7 +85,7 @@ def is_experimental(base: Optional[str]) -> bool: return False @overrides - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: command_chain = ["snap/command-chain/desktop-launch"] if self.yaml_data["base"] == "core24": command_chain.insert(0, "snap/command-chain/gpu-2404-wrapper") diff --git a/snapcraft/extensions/kde_neon.py b/snapcraft/extensions/kde_neon.py index e8ad16a476..a6c53b8267 100644 --- a/snapcraft/extensions/kde_neon.py +++ b/snapcraft/extensions/kde_neon.py @@ -89,7 +89,7 @@ def is_experimental(base: Optional[str]) -> bool: return False @overrides - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return { "command-chain": ["snap/command-chain/desktop-launch"], "plugs": ["desktop", "desktop-legacy", "opengl", "wayland", "x11"], diff --git a/snapcraft/extensions/kde_neon_6.py b/snapcraft/extensions/kde_neon_6.py index 20b85ae77e..8a9e6468af 100644 --- a/snapcraft/extensions/kde_neon_6.py +++ b/snapcraft/extensions/kde_neon_6.py @@ -88,7 +88,7 @@ def is_experimental(base: Optional[str]) -> bool: return False @overrides - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return { "command-chain": ["snap/command-chain/desktop-launch6"], "plugs": [ diff --git a/snapcraft/extensions/ros2_humble.py b/snapcraft/extensions/ros2_humble.py index 56f33f56dc..5467c3d884 100644 --- a/snapcraft/extensions/ros2_humble.py +++ b/snapcraft/extensions/ros2_humble.py @@ -87,7 +87,7 @@ def get_root_snippet(self) -> Dict[str, Any]: } @overrides - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: python_paths = [ f"$SNAP/opt/ros/{self.ROS_DISTRO}/lib/python3.10/site-packages", "$SNAP/usr/lib/python3/dist-packages", diff --git a/snapcraft/extensions/ros2_jazzy.py b/snapcraft/extensions/ros2_jazzy.py index 635d23fd2a..ae17efd5ba 100644 --- a/snapcraft/extensions/ros2_jazzy.py +++ b/snapcraft/extensions/ros2_jazzy.py @@ -85,7 +85,7 @@ def get_root_snippet(self) -> Dict[str, Any]: } @overrides - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: python_paths = [ f"$SNAP/opt/ros/{self.ROS_DISTRO}/lib/python3.12/site-packages", "$SNAP/usr/lib/python3/dist-packages", diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 3708e5aa3c..56cd864798 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -97,7 +97,7 @@ def is_experimental(base: Optional[str] = None) -> bool: def get_root_snippet(self) -> Dict[str, Any]: return {"grade": "fake-grade"} - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return {"plugs": ["fake-plug"]} def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: @@ -136,7 +136,7 @@ def is_experimental(base: Optional[str] = None) -> bool: def get_root_snippet(self) -> Dict[str, Any]: return {} - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return {"plugs": ["fake-plug", "fake-plug-extra"]} def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: @@ -170,7 +170,7 @@ def is_experimental(base: Optional[str] = None) -> bool: def get_root_snippet(self) -> Dict[str, Any]: return {"grade": "fake-grade"} - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return {"plugs": ["fake-plug"]} def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: @@ -206,7 +206,7 @@ def is_experimental(base: Optional[str] = None) -> bool: def get_root_snippet(self) -> Dict[str, Any]: return {} - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return {} def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: @@ -242,7 +242,7 @@ def is_experimental(base: Optional[str] = None) -> bool: def get_root_snippet(self) -> Dict[str, Any]: return {} - def get_app_snippet(self) -> Dict[str, Any]: + def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]: return {"plugs": ["fake-plug", "fake-plug-extra"]} def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]: diff --git a/tests/unit/extensions/test_gnome.py b/tests/unit/extensions/test_gnome.py index 7276dbb402..217194a2ce 100644 --- a/tests/unit/extensions/test_gnome.py +++ b/tests/unit/extensions/test_gnome.py @@ -81,14 +81,14 @@ def test_is_experimental(base): def test_get_app_snippet(gnome_extension): - assert gnome_extension.get_app_snippet() == { + assert gnome_extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/desktop-launch"], "plugs": ["desktop", "desktop-legacy", "gsettings", "opengl", "wayland", "x11"], } def test_get_app_snippet_core24(gnome_extension_core24): - assert gnome_extension_core24.get_app_snippet() == { + assert gnome_extension_core24.get_app_snippet(app_name="test-app") == { "command-chain": [ "snap/command-chain/gpu-2404-wrapper", "snap/command-chain/desktop-launch", diff --git a/tests/unit/extensions/test_kde_neon.py b/tests/unit/extensions/test_kde_neon.py index dda264abb4..35387a2a62 100644 --- a/tests/unit/extensions/test_kde_neon.py +++ b/tests/unit/extensions/test_kde_neon.py @@ -81,7 +81,7 @@ def test_is_experimental(): def test_get_app_snippet(kde_neon_extension): - assert kde_neon_extension.get_app_snippet() == { + assert kde_neon_extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/desktop-launch"], "plugs": ["desktop", "desktop-legacy", "opengl", "wayland", "x11"], } diff --git a/tests/unit/extensions/test_kde_neon_6.py b/tests/unit/extensions/test_kde_neon_6.py index 564e432a7d..df90609a8a 100644 --- a/tests/unit/extensions/test_kde_neon_6.py +++ b/tests/unit/extensions/test_kde_neon_6.py @@ -88,7 +88,7 @@ def test_is_experimental(): def test_get_app_snippet(kde_neon_6_extension): - assert kde_neon_6_extension.get_app_snippet() == { + assert kde_neon_6_extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/desktop-launch6"], "plugs": [ "desktop", diff --git a/tests/unit/parts/extensions/test_ros2_humble.py b/tests/unit/parts/extensions/test_ros2_humble.py index 53ad5b921b..4bbd91d771 100644 --- a/tests/unit/parts/extensions/test_ros2_humble.py +++ b/tests/unit/parts/extensions/test_ros2_humble.py @@ -110,7 +110,7 @@ def test_get_app_snippet(self, setup_method_fixture): "${PYTHONPATH}", ] extension = setup_method_fixture() - assert extension.get_app_snippet() == { + assert extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/ros2-launch"], "environment": { "ROS_VERSION": "2", diff --git a/tests/unit/parts/extensions/test_ros2_humble_meta.py b/tests/unit/parts/extensions/test_ros2_humble_meta.py index 67a439be02..1ec41625b2 100644 --- a/tests/unit/parts/extensions/test_ros2_humble_meta.py +++ b/tests/unit/parts/extensions/test_ros2_humble_meta.py @@ -142,7 +142,7 @@ def test_get_app_snippet(self, extension_name, extension_class, meta, meta_dev): "$SNAP/opt/ros/underlay_ws/usr/lib/python3/dist-packages", ] extension = setup_method_fixture(extension_class) - assert extension.get_app_snippet() == { + assert extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/ros2-launch"], "environment": { "ROS_VERSION": "2", diff --git a/tests/unit/parts/extensions/test_ros2_jazzy.py b/tests/unit/parts/extensions/test_ros2_jazzy.py index 664d52ad7b..8a33a13d51 100644 --- a/tests/unit/parts/extensions/test_ros2_jazzy.py +++ b/tests/unit/parts/extensions/test_ros2_jazzy.py @@ -110,7 +110,7 @@ def test_get_app_snippet(self, setup_method_fixture): "${PYTHONPATH}", ] extension = setup_method_fixture() - assert extension.get_app_snippet() == { + assert extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/ros2-launch"], "environment": { "ROS_VERSION": "2", diff --git a/tests/unit/parts/extensions/test_ros2_jazzy_meta.py b/tests/unit/parts/extensions/test_ros2_jazzy_meta.py index 7f5b996220..a772858e2b 100644 --- a/tests/unit/parts/extensions/test_ros2_jazzy_meta.py +++ b/tests/unit/parts/extensions/test_ros2_jazzy_meta.py @@ -142,7 +142,7 @@ def test_get_app_snippet(self, extension_name, extension_class, meta, meta_dev): "$SNAP/opt/ros/underlay_ws/usr/lib/python3/dist-packages", ] extension = setup_method_fixture(extension_class) - assert extension.get_app_snippet() == { + assert extension.get_app_snippet(app_name="test-app") == { "command-chain": ["snap/command-chain/ros2-launch"], "environment": { "ROS_VERSION": "2",