Skip to content

Remove PyProject From Interface __init__ #24

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 69 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7353411
Comments and Style
Behemyth Dec 19, 2021
c2c80a8
More Comments
Behemyth Dec 19, 2021
b889379
Update Pytest Library Fixtures
Behemyth Dec 22, 2021
a8be9bb
Update pdm.lock
Behemyth Jan 11, 2022
8ceffd1
Fix Test Discovery
Behemyth Jan 11, 2022
6fade4e
Changes
Behemyth Jan 13, 2022
d0a48be
Broken Test
Behemyth Jan 14, 2022
69c0850
Ya
Behemyth Jan 14, 2022
a3bdf79
Update Versioning
Behemyth Jan 19, 2022
1685aa6
Update Versions
Behemyth Jan 27, 2022
24e3bac
Typing
Behemyth Feb 1, 2022
ac665f4
More Type Fixing
Behemyth Feb 2, 2022
c843f49
Update Chore
Behemyth Feb 3, 2022
1ab173b
Docstrings
Behemyth Feb 3, 2022
987bdd1
Update Chore
Behemyth Feb 4, 2022
7419d21
Add Defaults
Behemyth Feb 5, 2022
018e6a2
Fix Tests
Behemyth Feb 6, 2022
0c343bc
Add Schema Test
Behemyth Feb 6, 2022
921cbee
us
Behemyth Feb 6, 2022
52c2e27
Remove Unused
Behemyth Feb 6, 2022
bee8241
Removed Unused Tests
Behemyth Feb 6, 2022
506548e
Removed duplicated schema tests
Behemyth Feb 6, 2022
f1cb0ce
Update Chore
Behemyth Feb 7, 2022
890aab1
Plugin Tests + Remove MP Tests
Behemyth Feb 7, 2022
9f1e7d1
Remove x-dist
Behemyth Feb 7, 2022
a7485b3
Proper Entry Points
Behemyth Feb 8, 2022
7699b2e
Remove Interface Plugin + Update Chore
Behemyth Feb 8, 2022
3d36713
Strip Project to Essentials
Behemyth Feb 9, 2022
891d5df
Type Cleanup
Behemyth Feb 9, 2022
2f4b109
Data
Behemyth Feb 9, 2022
3ec5498
Update Plugin Test
Behemyth Feb 9, 2022
19ceac5
Tests
Behemyth Feb 9, 2022
1491bd2
Integration Tests
Behemyth Feb 10, 2022
ef07902
Pydantic Types
Behemyth Feb 10, 2022
5104c1d
Chores
Behemyth Feb 11, 2022
b5733ac
Type Cleanup
Behemyth Feb 11, 2022
a1dc394
Type Fixes
Behemyth Feb 11, 2022
c6ee3af
Remove Outdated Tests
Behemyth Feb 11, 2022
048a369
Readd Generator Read
Behemyth Feb 11, 2022
21cdcf2
Update Chore
Behemyth Feb 12, 2022
e30769a
Fix Tests
Behemyth Feb 12, 2022
90b5d60
Comments
Behemyth Feb 12, 2022
bd65745
Pass through Data
Behemyth Feb 12, 2022
50cd1e0
Fix CMake Tests
Behemyth Feb 12, 2022
0e2bd77
Chore
Behemyth Feb 13, 2022
1243dcf
Call install
Behemyth Feb 13, 2022
9de7904
Remove conftest
Behemyth Feb 13, 2022
d76a8bf
Comments
Behemyth Feb 14, 2022
e06afad
Command Update
Behemyth Feb 14, 2022
b754e0e
test_interface
Behemyth Feb 14, 2022
c746a1e
Test Comments
Behemyth Feb 15, 2022
ff80734
SchemaTODOs
Behemyth Feb 15, 2022
9a468a5
More TODOs
Behemyth Feb 15, 2022
aea4635
Fix TODOs
Behemyth Feb 15, 2022
caac57e
Update Workflow
Behemyth Feb 16, 2022
7f79597
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Feb 16, 2022
47c0771
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Feb 16, 2022
bc7fd33
Update Release Again
Behemyth Feb 16, 2022
8325008
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Feb 16, 2022
750dff2
Remove Test Publish + Move Secret
Behemyth Feb 16, 2022
643daa7
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Feb 16, 2022
dde86ca
Change Upload Location
Behemyth Feb 16, 2022
f81cb7c
Remove Draft Workflow
Behemyth Feb 16, 2022
20d3e85
Remove Interface Plugin Entry
Behemyth Feb 16, 2022
89a0150
Update Version Chores
Behemyth Feb 23, 2022
1777e3d
Add Documentation
Behemyth Feb 24, 2022
ede27fd
Replace Interface
Behemyth Mar 6, 2022
ce8e7ee
Remove Unused Import
Behemyth Mar 6, 2022
52bea4e
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Mar 6, 2022
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
10 changes: 0 additions & 10 deletions .github/workflows/draft.yml

This file was deleted.

6 changes: 3 additions & 3 deletions cppython/plugins/interface/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tomlkit

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


def _create_pyproject():
Expand Down Expand Up @@ -41,10 +41,10 @@ def __init__(self):
pyproject = _create_pyproject()

# Initialize the object hook into CPPython
interface = ConsoleInterface(pyproject)
interface = ConsoleInterface()

# Initialize the CPPython context
self.project = Project(interface)
self.project = Project(interface, pyproject)


pass_config = click.make_pass_decorator(Config)
Expand Down
5 changes: 3 additions & 2 deletions cppython/plugins/test/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest

from cppython.plugins.test.data import default_pyproject
from cppython.project import Project
from cppython.schema import Generator, Interface

Expand All @@ -32,7 +33,7 @@ class GeneratorIntegrationTests(GeneratorTests):

def test_plugin_registration(self, generator: Generator):
"""
TODO
Test the registration with setuptools entry_points
"""
plugin_entries = entry_points(group=f"cppython.{generator.plugin_group()}")
assert len(plugin_entries) > 0
Expand Down Expand Up @@ -86,7 +87,7 @@ def test_project(self, interface: Interface):
"""
Test that the project can be constructed from the given interface
"""
Project(interface)
Project(interface, default_pyproject)


class InterfaceUnitTests(InterfaceTests):
Expand Down
12 changes: 5 additions & 7 deletions cppython/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from typing import Callable, Optional, Type, TypeVar

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


class Project(API):
"""
The object constructed at each entry_point
"""

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

self._interface = interface

Expand All @@ -35,15 +35,13 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool])

return None

plugin_type = find_plugin_type(Generator, lambda name: name == interface.pyproject.cppython_data.generator)
plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython_data.generator)

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

generator_data = interface.read_generator_data(plugin_type.data_type())
self._generator = plugin_type(interface.pyproject, generator_data)
self._generator = plugin_type(pyproject, generator_data)
self._generator.install_generator()

# API Contract
Expand Down
25 changes: 1 addition & 24 deletions cppython/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class Plugin(ABC):
Abstract plugin type
"""

@abstractmethod
def __init__(self) -> None:
pass

@staticmethod
@abstractmethod
def plugin_group() -> str:
Expand All @@ -120,26 +116,6 @@ class Interface:
Abstract type to be inherited by CPPython interfaces
"""

def __init__(self, pyproject: PyProject) -> None:
super().__init__()

self.pyproject = pyproject

@property
def pyproject(self) -> PyProject:
"""
PyProject getter
"""
return self._pyproject

@pyproject.setter
def pyproject(self, value: PyProject):
"""
PyProject setter
"""

self._pyproject = value

@abstractmethod
def read_generator_data(self, generator_data_type: Type[GeneratorDataType]) -> GeneratorDataType:
"""
Expand Down Expand Up @@ -194,3 +170,4 @@ def install_generator(self) -> bool:
Installs the external tooling required by the generator if necessary
Returns whether anything was installed or not
"""
raise NotImplementedError()
130 changes: 65 additions & 65 deletions pdm.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ cppython = "cppython.plugins.interface.console:cli"
[project.entry-points."cppython.generator_plugins"]
cmake = "cppython.plugins.generator.cmake:CMakeGenerator"

[project.entry-points."cppython.interface_plugins"]
console = "cppython.plugins.interface.console:ConsoleInterface"

# Pytest plugins
[tool.entry-points.pytest11]
pytest_cppython = "cppython.plugins.test.pytest"
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest

from cppython.plugins.interface.console import ConsoleInterface
from cppython.plugins.test.data import default_pyproject
from cppython.plugins.test.pytest import InterfaceIntegrationTests


Expand All @@ -22,4 +21,4 @@ def fixture_interface(self):
Returns:
ConsoleInterface -- The Interface object to use for the CPPython defined tests
"""
return ConsoleInterface(default_pyproject)
return ConsoleInterface()
2 changes: 1 addition & 1 deletion tests/unit/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def fixture_interface(self) -> ConsoleInterface:
Returns:
ConsoleInterface -- The Interface object to use for the CPPython defined tests
"""
return ConsoleInterface(default_pyproject)
return ConsoleInterface()

# Grab the API methods and parameterize them for automatic testing of the entry_points
method_list = [func for func in dir(API) if callable(getattr(API, func)) and not func.startswith("__")]
Expand Down