Skip to content

Commit

Permalink
refactor: use craft-application plugins register
Browse files Browse the repository at this point in the history
  • Loading branch information
syu-w committed Jan 18, 2024
1 parent b3bc4d7 commit 9a3b33b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 36 deletions.
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

0 comments on commit 9a3b33b

Please sign in to comment.