Skip to content

Commit 5ca24da

Browse files
authored
Use Updated Plugins (#29)
1 parent 03b93bd commit 5ca24da

16 files changed

+83
-487
lines changed

cppython/plugins/interface/console.py renamed to cppython/console.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import click
99
import tomlkit
10+
from cppython_core.schema import GeneratorDataType, Interface, PyProject
1011

1112
from cppython.project import Project
12-
from cppython.schema import GeneratorDataType, Interface, PyProject
1313

1414

1515
def _create_pyproject():
@@ -111,4 +111,7 @@ def write_pyproject(self) -> None:
111111
"""
112112

113113
def print(self, string: str) -> None:
114+
"""
115+
TODO
116+
"""
114117
click.echo(string)

cppython/plugins/test/data.py renamed to cppython/data.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
from pathlib import Path
66

7-
from cppython.schema import PEP621, CPPythonData, PyProject, TargetEnum
7+
from cppython_core.schema import PEP621, CPPythonData, PyProject, TargetEnum, ToolData
88

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

1111
# CMake is a default plugin
1212
default_cppython_data = CPPythonData(**{"generator": "cmake", "target": TargetEnum.EXE, "install-path": Path()})
13-
14-
default_pyproject = PyProject(project=default_pep621, cppython=default_cppython_data)
13+
default_tool_data = ToolData(**{"cppython": default_cppython_data})
14+
default_pyproject = PyProject(**{"project": default_pep621, "tool": default_tool_data})

cppython/exceptions.py

-24
This file was deleted.

cppython/plugins/generator/__init__.py

-1
This file was deleted.

cppython/plugins/generator/cmake.py

-59
This file was deleted.

cppython/plugins/interface/__init__.py

-1
This file was deleted.

cppython/plugins/test/__init__.py

-1
This file was deleted.

cppython/plugins/test/pytest.py

-97
This file was deleted.

cppython/project.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from importlib import metadata
66
from typing import Callable, Optional, Type, TypeVar
77

8-
from cppython.exceptions import ConfigError
9-
from cppython.schema import API, Generator, Interface, Plugin, PyProject
8+
from cppython_core.exceptions import ConfigError
9+
from cppython_core.schema import API, Generator, Interface, Plugin, PyProject
1010

1111

1212
class Project(API):
@@ -16,11 +16,16 @@ class Project(API):
1616

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

19-
self.enabled = pyproject.cppython is not None
19+
self.enabled = False
2020

21-
if not self.enabled:
21+
if pyproject.tool is None:
2222
return
2323

24+
if pyproject.tool.cppython is None:
25+
return
26+
27+
self.enabled = True
28+
2429
self._interface = interface
2530

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

4146
return None
4247

43-
plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython.generator)
48+
plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.tool.cppython.generator)
4449

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

4853
generator_data = interface.read_generator_data(plugin_type.data_type())
4954
self._generator = plugin_type(pyproject, generator_data)
@@ -52,11 +57,11 @@ def download(self):
5257
"""
5358
Download the generator tooling if required
5459
"""
55-
if not self._generator.downloaded():
60+
if not self._generator.generator_downloaded():
5661
self._interface.print(f"Downloading the {self._generator.name()} tool")
5762

5863
# TODO: Make async with progress bar
59-
self._generator.download()
64+
self._generator.download_generator()
6065
self._interface.print("Download complete")
6166

6267
# API Contract

0 commit comments

Comments
 (0)