Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use craft-application plugins register #457

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ click==8.1.7
codespell==2.2.6
colorama==0.4.6
coverage==7.4.0
craft-application==1.2.0
craft-application @ git+https://github.com/canonical/craft-application@CRAFT-2401-support-plugins
craft-archives==1.1.3
craft-cli==2.5.0
craft-parts==1.26.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
certifi==2023.11.17
charset-normalizer==3.3.2
craft-application==1.2.0
craft-application @ git+https://github.com/canonical/craft-application@CRAFT-2401-support-plugins
craft-archives==1.1.3
craft-cli==2.5.0
craft-parts==1.26.1
Expand Down
7 changes: 7 additions & 0 deletions rockcraft/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
from typing import Any

from craft_application import Application, AppMetadata, util
from craft_parts.plugins.plugins import PluginType
from overrides import override # type: ignore[reportUnknownVariableType]

from rockcraft import models
from rockcraft.models import project
from rockcraft.plugins.python_plugin import PythonPlugin

APP_METADATA = AppMetadata(
name="rockcraft",
Expand All @@ -35,6 +37,11 @@
class Rockcraft(Application):
"""Rockcraft application definition."""

@override
def _get_app_plugins(self) -> dict[str, PluginType]:
"""Register Rockcraft plugins."""
return {"python": PythonPlugin}

@override
def _extra_yaml_transform(self, yaml_data: dict[str, Any]) -> dict[str, Any]:
return models.transform_yaml(self._work_dir, yaml_data)
Expand Down
5 changes: 0 additions & 5 deletions rockcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import logging
from typing import TYPE_CHECKING

from rockcraft import plugins

from . import commands
from .services import RockcraftServiceFactory

Expand All @@ -30,9 +28,6 @@

def run() -> int:
"""Command-line interface entrypoint."""
# Register our own plugins
plugins.register()

# set lib loggers to debug level so that all messages are sent to Emitter
for lib_name in ("craft_providers", "craft_parts"):
logger = logging.getLogger(lib_name)
Expand Down
3 changes: 1 addition & 2 deletions rockcraft/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
"""Rockcraft-specific plugins."""

from .python_plugin import PythonPlugin
from .register import register

__all__ = ["PythonPlugin", "register"]
__all__ = ["PythonPlugin"]
26 changes: 0 additions & 26 deletions rockcraft/plugins/register.py

This file was deleted.

3 changes: 2 additions & 1 deletion tests/integration/plugins/test_python_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from dataclasses import dataclass
from pathlib import Path

import craft_parts.plugins
import pytest
from craft_application import errors
from craft_cli import EmitterMode, emit
Expand All @@ -44,7 +45,7 @@ def setup_python_test(monkeypatch):
# Keep craft-parts from trying to refresh apt's cache, so that we can run
# this test as regular users.
monkeypatch.setenv("CRAFT_PARTS_PACKAGE_REFRESH", "0")
plugins.register()
craft_parts.plugins.register({"python": plugins.PythonPlugin})


def create_python_project(base, extra_part_props=None) -> Project:
Expand Down