Skip to content

Use Updated Plugins #29

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

Merged
merged 19 commits into from
Mar 14, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import click
import tomlkit
from cppython_core.schema import GeneratorDataType, Interface, PyProject

from cppython.project import Project
from cppython.schema import GeneratorDataType, Interface, PyProject


def _create_pyproject():
Expand Down Expand Up @@ -111,4 +111,7 @@ def write_pyproject(self) -> None:
"""

def print(self, string: str) -> None:
"""
TODO
"""
click.echo(string)
6 changes: 3 additions & 3 deletions cppython/plugins/test/data.py → cppython/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from pathlib import Path

from cppython.schema import PEP621, CPPythonData, PyProject, TargetEnum
from cppython_core.schema import PEP621, CPPythonData, PyProject, TargetEnum, ToolData

default_pep621 = PEP621(name="test_name", version="1.0")

# CMake is a default plugin
default_cppython_data = CPPythonData(**{"generator": "cmake", "target": TargetEnum.EXE, "install-path": Path()})

default_pyproject = PyProject(project=default_pep621, cppython=default_cppython_data)
default_tool_data = ToolData(**{"cppython": default_cppython_data})
default_pyproject = PyProject(**{"project": default_pep621, "tool": default_tool_data})
24 changes: 0 additions & 24 deletions cppython/exceptions.py

This file was deleted.

1 change: 0 additions & 1 deletion cppython/plugins/generator/__init__.py

This file was deleted.

59 changes: 0 additions & 59 deletions cppython/plugins/generator/cmake.py

This file was deleted.

1 change: 0 additions & 1 deletion cppython/plugins/interface/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion cppython/plugins/test/__init__.py

This file was deleted.

97 changes: 0 additions & 97 deletions cppython/plugins/test/pytest.py

This file was deleted.

21 changes: 13 additions & 8 deletions cppython/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from importlib import metadata
from typing import Callable, Optional, Type, TypeVar

from cppython.exceptions import ConfigError
from cppython.schema import API, Generator, Interface, Plugin, PyProject
from cppython_core.exceptions import ConfigError
from cppython_core.schema import API, Generator, Interface, Plugin, PyProject


class Project(API):
Expand All @@ -16,11 +16,16 @@ class Project(API):

def __init__(self, interface: Interface, pyproject: PyProject) -> None:

self.enabled = pyproject.cppython is not None
self.enabled = False

if not self.enabled:
if pyproject.tool is None:
return

if pyproject.tool.cppython is None:
return

self.enabled = True

self._interface = interface

PluginType = TypeVar("PluginType", bound=Type[Plugin])
Expand All @@ -40,10 +45,10 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool])

return None

plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython.generator)
plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.tool.cppython.generator)

if plugin_type is None:
raise ConfigError(f"No generator plugin with the name '{pyproject.cppython.generator}' was found.")
raise ConfigError(f"No generator plugin with the name '{pyproject.tool.cppython.generator}' was found.")

generator_data = interface.read_generator_data(plugin_type.data_type())
self._generator = plugin_type(pyproject, generator_data)
Expand All @@ -52,11 +57,11 @@ def download(self):
"""
Download the generator tooling if required
"""
if not self._generator.downloaded():
if not self._generator.generator_downloaded():
self._interface.print(f"Downloading the {self._generator.name()} tool")

# TODO: Make async with progress bar
self._generator.download()
self._generator.download_generator()
self._interface.print("Download complete")

# API Contract
Expand Down
Loading