Skip to content

Update Dependencies #40

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 1 commit into from
Apr 16, 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
27 changes: 13 additions & 14 deletions cppython/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dataclasses import dataclass
from importlib import metadata
from pathlib import Path
from typing import Any, Type, TypeVar
from xmlrpc.client import Boolean

Expand Down Expand Up @@ -98,7 +99,6 @@ def __init__(
self, configuration: ProjectConfiguration, interface: Interface, pyproject_data: dict[str, Any]
) -> None:

self.enabled = False
self.configuration = configuration

if self.configuration.verbose:
Expand All @@ -113,60 +113,59 @@ def __init__(
return

extended_pyproject_type = builder.generate_model(plugins)
pyproject = extended_pyproject_type(**pyproject_data)
self.pyproject = extended_pyproject_type(**pyproject_data)

if pyproject.tool is None:
if self.pyproject.tool is None:
if self.configuration.verbose:
interface.print("Table [tool] is not defined")
return

if pyproject.tool.cppython is None:
if self.pyproject.tool.cppython is None:
if self.configuration.verbose:
interface.print("Table [tool.cppython] is not defined")
return

self.enabled = True

self._interface = interface
self._generators = builder.create_generators(plugins, pyproject)
self._generators = builder.create_generators(plugins, self.pyproject)

if self.configuration.verbose:
interface.print("CPPython project initialized")

def download(self):
def download(self, path: Path):
"""
Download the generator tooling if required
"""

for generator in self._generators:

if not generator.generator_downloaded():
if not generator.generator_downloaded(path):
self._interface.print(f"Downloading the {generator.name()} tool")

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

# API Contract

def install(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Installing...")
self.download()
self.download(self.pyproject.tool.cppython.install_path)

for generator in self._generators:
generator.install()

def update(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Updating...")

for generator in self._generators:
generator.update()

def build(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Building...")

Expand Down
21 changes: 11 additions & 10 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dynamic = ["version"]
requires-python = ">=3.10"

dependencies = [
"click>=8.0.3",
"tomlkit>=0.10.0",
"cppython-core>=0.1.4",
"click>=8.1.2",
"tomlkit>=0.10.1",
"cppython-core>=0.2.1",
"pydantic>=1.9.0",
]

Expand All @@ -40,7 +40,7 @@ test = [
"pytest>=7.1.1",
"pytest-cov>=3.0.0",
"pytest-mock>=3.7.0",
"pytest-cppython>=0.1.0",
"pytest-cppython>=0.1.4",
]

[project.scripts]
Expand Down
11 changes: 8 additions & 3 deletions tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def test_construction(self, mocker: MockerFixture):

interface_mock = mocker.MagicMock()
configuration = ProjectConfiguration()
Project(configuration, interface_mock, default_pyproject.dict())
Project(configuration, interface_mock, default_pyproject.dict(by_alias=True))

def test_download(self):
"""
TODO
"""


class TestBuilder:
Expand Down Expand Up @@ -65,10 +70,10 @@ def test_generator_data_construction(self, mocker: MockerFixture):

model_type = builder.generate_model([generator_type])

project_data = default_pyproject.dict()
project_data = default_pyproject.dict(by_alias=True)

mock_data = MockGeneratorData(check=True)
project_data["tool"]["cppython"]["mock"] = mock_data.dict()
project_data["tool"]["cppython"]["mock"] = mock_data.dict(by_alias=True)
result = model_type(**project_data)

assert result.tool is not None
Expand Down