diff --git a/cppython/plugins/interface/console.py b/cppython/console.py similarity index 95% rename from cppython/plugins/interface/console.py rename to cppython/console.py index 3137a8d..b3699d7 100644 --- a/cppython/plugins/interface/console.py +++ b/cppython/console.py @@ -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(): @@ -111,4 +111,7 @@ def write_pyproject(self) -> None: """ def print(self, string: str) -> None: + """ + TODO + """ click.echo(string) diff --git a/cppython/plugins/test/data.py b/cppython/data.py similarity index 52% rename from cppython/plugins/test/data.py rename to cppython/data.py index abdee63..61551b9 100644 --- a/cppython/plugins/test/data.py +++ b/cppython/data.py @@ -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}) diff --git a/cppython/exceptions.py b/cppython/exceptions.py deleted file mode 100644 index c9d3102..0000000 --- a/cppython/exceptions.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Custom exceptions used by CPPython -""" - - -class ConfigError(Exception): - """ - Raised when there is a configuration error - """ - - def __init__(self, error: str) -> None: - self._error = error - - super().__init__(error) - - @property - def error(self) -> str: - """ - Returns the underlying error - - Returns: - str -- The underlying error - """ - return self._error diff --git a/cppython/plugins/generator/__init__.py b/cppython/plugins/generator/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/generator/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py deleted file mode 100644 index 3f708c9..0000000 --- a/cppython/plugins/generator/cmake.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -The default generator implementation for CPPython -""" -from typing import Type - -from cppython.schema import Generator, GeneratorData, PyProject - - -class CMakeData(GeneratorData): - """ - The data schema required for the CMake tooling - """ - - -class CMakeGenerator(Generator): - """ - A CPPython generator implementing a CMake backend - """ - - def __init__(self, pyproject: PyProject, cmake_data: CMakeData) -> None: - self.data = cmake_data - - @staticmethod - def name() -> str: - """ - The name of the generator - """ - return "cmake" - - @staticmethod - def data_type() -> Type[GeneratorData]: - """ - Returns the pydantic type to cast the generator configuration data to - """ - return CMakeData - - def generator_downloaded(self) -> bool: - - # CMake tooling is a part of the python package tooling - return True - - def download_generator(self) -> None: - """ - Installs the external tooling required by the generator if necessary - """ - - def update_generator(self) -> None: - """ - Update the tooling required by the generator - """ - - def install(self) -> None: - raise NotImplementedError() - - def update(self) -> None: - raise NotImplementedError() - - def build(self) -> None: - raise NotImplementedError() diff --git a/cppython/plugins/interface/__init__.py b/cppython/plugins/interface/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/interface/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/plugins/test/__init__.py b/cppython/plugins/test/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/test/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/plugins/test/pytest.py b/cppython/plugins/test/pytest.py deleted file mode 100644 index 0a120f8..0000000 --- a/cppython/plugins/test/pytest.py +++ /dev/null @@ -1,97 +0,0 @@ -""" -Helper fixtures and plugin definitions for pytest -TODO: Should by a pytest plugin, removing the need for this module in production code. -""" -from abc import ABC -from importlib.metadata import entry_points - -import pytest - -from cppython.plugins.test.data import default_pyproject -from cppython.project import Project -from cppython.schema import Generator, Interface - - -class GeneratorTests(ABC): - """ - Shared functionality between the different Generator testing categories - """ - - @pytest.fixture(name="generator") - def fixture_generator(self) -> Generator: - """ - A hook allowing implementations to override the fixture with a parameterization - @pytest.mark.parametrize("generator", [CustomGenerator]) - """ - raise NotImplementedError - - -class GeneratorIntegrationTests(GeneratorTests): - """ - Base class for all generator integration tests that test plugin agnostic behavior - """ - - def test_plugin_registration(self, generator: Generator): - """ - Test the registration with setuptools entry_points - """ - plugin_entries = entry_points(group=f"cppython.{generator.plugin_group()}") - assert len(plugin_entries) > 0 - - -class GeneratorUnitTests(GeneratorTests): - """ - Custom implementations of the Generator class should inherit from this class for its tests. - Base class for all generator unit tests that test plugin agnostic behavior - """ - - def test_name(self, generator: Generator): - """ - Test name restrictions - TODO: This should be a pydantic schema - """ - name = generator.name() - - assert name != "" - - def test_data_type(self, generator: Generator): - """ - Test data_type restrictions - TODO: This should be a pydantic schema - """ - data_type = generator.data_type() - - assert data_type != "" - - -class InterfaceTests(ABC): - """ - Shared functionality between the different Interface testing categories - """ - - @pytest.fixture(name="interface") - def fixture_interface(self) -> Interface: - """ - A hook allowing implementations to override the fixture with a parameterization - @pytest.mark.parametrize("interface", [CustomInterface]) - """ - raise NotImplementedError - - -class InterfaceIntegrationTests(InterfaceTests): - """ - Base class for all interface integration tests that test plugin agnostic behavior - """ - - def test_project(self, interface: Interface): - """ - Test that the project can be constructed from the given interface - """ - Project(interface, default_pyproject) - - -class InterfaceUnitTests(InterfaceTests): - """ - Custom implementations of the Interface class should inherit from this class for its tests. - Base class for all interface unit tests that test plugin agnostic behavior - """ diff --git a/cppython/project.py b/cppython/project.py index 6bd8d7d..b6991b5 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -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): @@ -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]) @@ -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) @@ -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 diff --git a/cppython/schema.py b/cppython/schema.py deleted file mode 100644 index 6c777bc..0000000 --- a/cppython/schema.py +++ /dev/null @@ -1,196 +0,0 @@ -""" -Data types for CPPython that encapsulate the requirements between the plugins and the core library -""" - -from abc import ABC, abstractmethod -from enum import Enum -from pathlib import Path -from typing import Optional, Type, TypeVar - -from pydantic import BaseModel -from pydantic.fields import Field - - -class TargetEnum(Enum): - """ - The C++ build target type - """ - - EXE = "executable" - STATIC = "static" - SHARED = "shared" - - -class PEP621(BaseModel): - """ - PEP 621 conforming data - The entirety of PEP 621 is not relevant for interface plugins - Schema: https://www.python.org/dev/peps/pep-0621/ - """ - - name: str - version: str - description: str = "" - - -class CPPythonData(BaseModel): - """ - Data required by the tool - """ - - generator: str - target: TargetEnum - dependencies: dict[str, str] = {} - install_path: Path = Field(alias="install-path") - - -class PyProject(BaseModel): - """ - pyproject.toml schema - """ - - project: PEP621 - cppython: Optional[CPPythonData] - - -class API(ABC): - """ - API - """ - - @abstractmethod - def install(self) -> None: - """ - Called when dependencies need to be installed from a lock file. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - @abstractmethod - def update(self) -> None: - """ - Called when dependencies need to be updated and written to the lock file. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - @abstractmethod - def build(self) -> None: - """ - Called when the C++ target needs to be produced. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - -class Plugin(ABC): - """ - Abstract plugin type - """ - - @staticmethod - @abstractmethod - def plugin_group() -> str: - """ - The plugin group name as used by 'setuptools' - """ - raise NotImplementedError() - - -class GeneratorData(BaseModel): - """ - Base class for the configuration data that will be read by the interface and given to the generator - """ - - -GeneratorDataType = TypeVar("GeneratorDataType", bound=GeneratorData) - - -class Interface: - """ - Abstract type to be inherited by CPPython interfaces - """ - - @abstractmethod - def read_generator_data(self, generator_data_type: Type[GeneratorDataType]) -> GeneratorDataType: - """ - Dynamic pyproject.toml data that is determined by the generator plugin requested by [tool.cppython.generator] - The Schema defined by 'generator_data_type' must be filled by the [tool.cppython.{generator_value}] slot. - """ - raise NotImplementedError() - - @abstractmethod - def write_pyproject(self) -> None: - """ - Called when CPPython requires the interface to write out pyproject.toml changes - """ - raise NotImplementedError() - - @abstractmethod - def print(self, string: str) -> None: - """ - Prints the given string into the Interface IO - """ - raise NotImplementedError() - - -class Generator(Plugin, API): - """ - Abstract type to be inherited by CPPython Generator plugins - """ - - @abstractmethod - def __init__(self, pyproject: PyProject, generator_data: GeneratorData) -> None: - """ - Allows CPPython to pass the relevant data to constructed Generator plugin - """ - - @staticmethod - def plugin_group() -> str: - """ - The plugin group name as used by 'setuptools' - """ - return "generator_plugins" - - @staticmethod - @abstractmethod - def name() -> str: - """ - The string that is matched with the [tool.cppython.generator] string - """ - raise NotImplementedError() - - @staticmethod - @abstractmethod - def data_type() -> Type[GeneratorData]: - """ - Returns the pydantic type to cast the generator configuration data to - """ - raise NotImplementedError() - - @abstractmethod - def generator_downloaded(self) -> bool: - """ - Returns whether the generator needs to be downloaded - """ - raise NotImplementedError() - - @abstractmethod - def download_generator(self) -> None: - """ - Installs the external tooling required by the generator - """ - raise NotImplementedError() - - @abstractmethod - def update_generator(self) -> None: - """ - Update the tooling required by the generator - """ - raise NotImplementedError() diff --git a/pdm.lock b/pdm.lock index d4bd678..8f258a8 100644 --- a/pdm.lock +++ b/pdm.lock @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "cmake" -version = "3.22.2" +version = "3.22.3" summary = "CMake is an open-source, cross-platform family of tools designed to build, test and package software" [[package]] @@ -71,6 +71,15 @@ dependencies = [ "tomli", ] +[[package]] +name = "cppython-core" +version = "0.1.0" +requires_python = ">=3.10" +summary = "Data definitions for CPPython" +dependencies = [ + "pydantic>=1.9", +] + [[package]] name = "iniconfig" version = "1.1.1" @@ -161,8 +170,8 @@ summary = "Python parsing module" [[package]] name = "pytest" -version = "7.0.1" -requires_python = ">=3.6" +version = "7.1.0" +requires_python = ">=3.7" summary = "pytest: simple powerful testing with Python" dependencies = [ "atomicwrites>=1.0; sys_platform == \"win32\"", @@ -185,6 +194,15 @@ dependencies = [ "pytest>=4.6", ] +[[package]] +name = "pytest-cppython" +version = "0.1.0" +requires_python = ">=3.10" +summary = "A pytest plugin that imports CPPython testing types" +dependencies = [ + "cppython-core>=0.1.0", +] + [[package]] name = "pytest-mock" version = "3.7.0" @@ -232,7 +250,7 @@ summary = "Module for decorators, wrappers and monkey patching." [metadata] lock_version = "3.1" -content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f7544cfc" +content_hash = "sha256:66626e32ae603a3def926a3b86656a48b98b2e4016a4646e24cbedde657d3f71" [metadata.files] "astroid 2.9.3" = [ @@ -276,23 +294,23 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"}, {file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"}, ] -"cmake 3.22.2" = [ - {file = "cmake-3.22.2-py2.py3-none-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:7bc1c50c9131105b4892528183475d3fc564f3d611f0fe2f1b1bd184f7de1fd4"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ccb57bf773fdc0d3d299da387f7d46f38b452608fdc3100aa294dbb25d216515"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0801156be44344de6b1427ee8e845850d113868001c4c5bd415caf8d44328b8f"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:43b820c4b880e28c10ff78ea0189deed77d77ddc166bb3fd807fa848a2822a25"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:026edb77648e9d84e2f446534a964513cf5ea82f226996bbe6dc480fb8048cf9"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6aff4053fb344dc3d89a3ebd4ef66dd6ba0c8bf0130a2fd3fb8c65baf7316518"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9bc25b9c8be9507f4fc2004931f0d2f680eeae7c00f6d21aa168839a8aee7432"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e01697d8beefd3cb2224aa70139858b6f515fc74348447fe97ddef8b56bf1cb9"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:457e4990e8459cacbe37df6fb1aaf9648d6d08788d8b5f526c46a19d3cd7b700"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:29eecf8285be72db820a60fa4adfc7b1f4c2acc0f3181881d191587ac5272e8c"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:87cce96f5bd40987741718462fa29138d17bb8dbd24cd2a3f0824d2210cac429"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:a642208015f3ffbc95dce55c23058ee7c562d3dece0da398f8d3276f45f5ee34"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:7f10f00b863f2c60b585ebb45ae048174d450982c2595f336fcbbd6695a50e19"}, - {file = "cmake-3.22.2-py2.py3-none-win32.whl", hash = "sha256:fd3168e2535ddd0bd9bfff0e4aeb921a61a8351c272654ba71b518da502b9ec2"}, - {file = "cmake-3.22.2-py2.py3-none-win_amd64.whl", hash = "sha256:9f5f563e89a3ee8873a4c48c69d8a32331749da3c3b657d0f0ac74b659e87954"}, - {file = "cmake-3.22.2.tar.gz", hash = "sha256:b5bd5eeb488b13cf64ec963800f3d979eaeb90b4382861b86909df503379e219"}, +"cmake 3.22.3" = [ + {file = "cmake-3.22.3-py2.py3-none-macosx_10_10_universal2.macosx_10_10_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:d387e4062541094d302c80b3beed08cfa4f2ef98454d04f34fd1071c595152d8"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9ff1a89c264a6645d5d222f73efe83ea47abc96d77ae96e3e4eb4580f6f396fc"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3adc8532f5029931e82c9ae6a07b5d866b216b422cedc72074155c80db6e27d7"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c46f0573b0455a234c397fff2f3679e18925eb3da32069cc41f1aab7cd968260"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86c68b283223375ff942bce5b9f2b286fa5ac94b02f848e52fcec2369a407b22"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:452e53346d52241fbebdb9487e88786221c92d4abfa59fb002dc928ada69399c"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fb5fbcb8b45c9f9823a1bffffe8eab673e463b8d36b258856035725e04baf446"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e615d29c2c26faf7e3876c47bafbab0eefe29683e01bec3a14736e9694bdff73"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:1d6096da730d2d0c8352926b647d0d340fc2ea3a6497dd13cff1c999d68d9d7b"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:d3be0f5256bfe76c81d2db30216c937a7f7cefd251fb63c1cb30c5e0a896bbad"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:d73961a801ea9e2fdda9afa3b9fc84539e368ecec30de1ef54045abfabce4ece"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:45e89f6ff37283ecff912c7fe65dc4bc6dfe2fb78b7747b95272dd7423a3847f"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:c776ad422f7ce3866497f132af4ba7240cb81d554ee5eb801fd5e2d8c7cd67d6"}, + {file = "cmake-3.22.3-py2.py3-none-win32.whl", hash = "sha256:8d32168fb3153313408befc7b8b5593130bad7d5fe0b8df764bb723b8c710bfc"}, + {file = "cmake-3.22.3-py2.py3-none-win_amd64.whl", hash = "sha256:d8db320fb36560fcf2ca66481009bc1d1f8ed45fd756ce91e4dee97026a0e3a4"}, + {file = "cmake-3.22.3.tar.gz", hash = "sha256:6e1d1991775915dac047af851f2feec7eb35ab4b4610d3e7fd94d93bce8faf58"}, ] "colorama 0.4.4" = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, @@ -341,6 +359,10 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "coverage-6.3.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:18d520c6860515a771708937d2f78f63cc47ab3b80cb78e86573b0a760161faf"}, {file = "coverage-6.3.2.tar.gz", hash = "sha256:03e2a7826086b91ef345ff18742ee9fc47a6839ccd517061ef8fa1976e652ce9"}, ] +"cppython-core 0.1.0" = [ + {file = "cppython_core-0.1.0-py3-none-any.whl", hash = "sha256:97a7c5132eb0fb4c5703d31509e73a746f66576957ebca77b216a50940153d40"}, + {file = "cppython-core-0.1.0.tar.gz", hash = "sha256:2993b038d0d2591be46a8afe6d21ec87c51f634d51d83fed10bd4b5c8ef2df50"}, +] "iniconfig 1.1.1" = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, @@ -461,14 +483,18 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, ] -"pytest 7.0.1" = [ - {file = "pytest-7.0.1-py3-none-any.whl", hash = "sha256:9ce3ff477af913ecf6321fe337b93a2c0dcf2a0a1439c43f5452112c1e4280db"}, - {file = "pytest-7.0.1.tar.gz", hash = "sha256:e30905a0c131d3d94b89624a1cc5afec3e0ba2fbdb151867d8e0ebd49850f171"}, +"pytest 7.1.0" = [ + {file = "pytest-7.1.0-py3-none-any.whl", hash = "sha256:b555252a95bbb2a37a97b5ac2eb050c436f7989993565f5e0c9128fcaacadd0e"}, + {file = "pytest-7.1.0.tar.gz", hash = "sha256:f1089d218cfcc63a212c42896f1b7fbf096874d045e1988186861a1a87d27b47"}, ] "pytest-cov 3.0.0" = [ {file = "pytest_cov-3.0.0-py3-none-any.whl", hash = "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6"}, {file = "pytest-cov-3.0.0.tar.gz", hash = "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"}, ] +"pytest-cppython 0.1.0" = [ + {file = "pytest_cppython-0.1.0-py3-none-any.whl", hash = "sha256:f243a909498a1271f0080a65b83b92ec48e92680bcbb28721a528d97f00c218c"}, + {file = "pytest-cppython-0.1.0.tar.gz", hash = "sha256:029e0088969ef8b3217d93ee95f2b3a2dcea607b4bfd16e5ed2427bc3f5da98b"}, +] "pytest-mock 3.7.0" = [ {file = "pytest_mock-3.7.0-py3-none-any.whl", hash = "sha256:6cff27cec936bf81dc5ee87f07132b807bcda51106b5ec4b90a04331cba76231"}, {file = "pytest-mock-3.7.0.tar.gz", hash = "sha256:5112bd92cc9f186ee96e1a92efc84969ea494939c3aead39c50f421c4cc69534"}, diff --git a/pyproject.toml b/pyproject.toml index a8d599a..2ca02b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,10 @@ requires-python = ">=3.10" dependencies = [ "click>=8.0.3", - "cmake>=3.22.2", + "cmake>=3.22.3", "pydantic>=1.9", - "tomlkit>=0.9", - "pytest>=7.0.0", # Required for testing injection + "tomlkit>=0.10.0", + "cppython-core>=0.1.0", ] [project.license-files] @@ -38,20 +38,14 @@ lint = [ "isort>=5.10.1", ] test = [ + "pytest>=7.1.0", "pytest-cov>=3.0.0", "pytest-mock>=3.7.0", + "pytest-cppython>=0.1.0", ] [project.scripts] -cppython = "cppython.plugins.interface.console:cli" - -# CPPython plugins -[project.entry-points."cppython.generator_plugins"] -cmake = "cppython.plugins.generator.cmake:CMakeGenerator" - -# Pytest plugins -[tool.entry-points.pytest11] -pytest_cppython = "cppython.plugins.test.pytest" +cppython = "cppython.console:cli" [tool.pytest.ini_options] testpaths = [ @@ -67,7 +61,6 @@ profile = "black" [tool.pylint.messages_control] disable = "C0330, C0326" -extension-pkg-whitelist = "pydantic" [tool.pylint.format] max-line-length = "120" diff --git a/tests/integration/test_generator.py b/tests/integration/test_generator.py deleted file mode 100644 index d3ccd5f..0000000 --- a/tests/integration/test_generator.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Test the integrations related to the internal generator implementation and the 'Generator' interface itself -""" - -import pytest - -from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.data import default_pyproject -from cppython.plugins.test.pytest import GeneratorIntegrationTests - - -class TestCMakeGenerator(GeneratorIntegrationTests): - """ - The tests for our CMake generator - """ - - @pytest.fixture(name="generator") - def fixture_generator(self): - """ - Override of the plugin provided generator fixture. - - Returns: - CMakeGenerator -- The Generator object to use for the CPPython defined tests - """ - cmake_data = CMakeData() - return CMakeGenerator(default_pyproject, cmake_data) diff --git a/tests/integration/test_interface.py b/tests/integration/test_interface.py index c749c2f..b05391b 100644 --- a/tests/integration/test_interface.py +++ b/tests/integration/test_interface.py @@ -3,9 +3,9 @@ """ import pytest +from pytest_cppython.plugin import InterfaceIntegrationTests -from cppython.plugins.interface.console import ConsoleInterface -from cppython.plugins.test.pytest import InterfaceIntegrationTests +from cppython.console import ConsoleInterface class TestCLIInterface(InterfaceIntegrationTests): diff --git a/tests/unit/test_generator.py b/tests/unit/test_generator.py deleted file mode 100644 index d8871fb..0000000 --- a/tests/unit/test_generator.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Test the functions related to the internal generator implementation and the 'Generator' interface itself -""" - -import pytest - -from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.data import default_pyproject -from cppython.plugins.test.pytest import GeneratorUnitTests - - -class TestCMakeGenerator(GeneratorUnitTests): - """ - The tests for our CMake generator - """ - - @pytest.fixture(name="generator") - def fixture_generator(self) -> CMakeGenerator: - """ - Override of the plugin provided generator fixture. - - Returns: - CMakeGenerator -- The Generator object to use for the CPPython defined tests - """ - cmake_data = CMakeData() - return CMakeGenerator(default_pyproject, cmake_data) diff --git a/tests/unit/test_interface.py b/tests/unit/test_interface.py index d8fa1d8..cf12fab 100644 --- a/tests/unit/test_interface.py +++ b/tests/unit/test_interface.py @@ -4,12 +4,12 @@ import pytest from click.testing import CliRunner +from cppython_core.schema import API +from pytest_cppython.plugin import InterfaceUnitTests from pytest_mock.plugin import MockerFixture -from cppython.plugins.interface.console import Config, ConsoleInterface, cli -from cppython.plugins.test.data import default_pyproject -from cppython.plugins.test.pytest import InterfaceUnitTests -from cppython.schema import API +from cppython.console import Config, ConsoleInterface, cli +from cppython.data import default_pyproject class TestCLIInterface(InterfaceUnitTests): @@ -43,7 +43,7 @@ def test_command(self, command: str, mocker: MockerFixture): mocker.patch("cppython.project.Project.__init__", return_value=None) # Patch the reading of data - mocker.patch("cppython.plugins.interface.console._create_pyproject", return_value=default_pyproject) + mocker.patch("cppython.console._create_pyproject", return_value=default_pyproject) config = Config()