Skip to content

Commit 9e35682

Browse files
authored
Update Dependencies (#40)
1 parent b9d31c9 commit 9e35682

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

cppython/project.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from dataclasses import dataclass
66
from importlib import metadata
7+
from pathlib import Path
78
from typing import Any, Type, TypeVar
89
from xmlrpc.client import Boolean
910

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

101-
self.enabled = False
102102
self.configuration = configuration
103103

104104
if self.configuration.verbose:
@@ -113,60 +113,59 @@ def __init__(
113113
return
114114

115115
extended_pyproject_type = builder.generate_model(plugins)
116-
pyproject = extended_pyproject_type(**pyproject_data)
116+
self.pyproject = extended_pyproject_type(**pyproject_data)
117117

118-
if pyproject.tool is None:
118+
if self.pyproject.tool is None:
119119
if self.configuration.verbose:
120120
interface.print("Table [tool] is not defined")
121121
return
122122

123-
if pyproject.tool.cppython is None:
123+
if self.pyproject.tool.cppython is None:
124124
if self.configuration.verbose:
125125
interface.print("Table [tool.cppython] is not defined")
126126
return
127127

128-
self.enabled = True
129-
130128
self._interface = interface
131-
self._generators = builder.create_generators(plugins, pyproject)
129+
self._generators = builder.create_generators(plugins, self.pyproject)
132130

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

136-
def download(self):
134+
def download(self, path: Path):
137135
"""
138136
Download the generator tooling if required
139137
"""
138+
140139
for generator in self._generators:
141140

142-
if not generator.generator_downloaded():
141+
if not generator.generator_downloaded(path):
143142
self._interface.print(f"Downloading the {generator.name()} tool")
144143

145144
# TODO: Make async with progress bar
146-
generator.download_generator()
145+
generator.download_generator(path)
147146
self._interface.print("Download complete")
148147

149148
# API Contract
150149

151150
def install(self) -> None:
152-
if self.enabled:
151+
if self.pyproject.tool and self.pyproject.tool.cppython:
153152
if self.configuration.verbose:
154153
self._interface.print("CPPython: Installing...")
155-
self.download()
154+
self.download(self.pyproject.tool.cppython.install_path)
156155

157156
for generator in self._generators:
158157
generator.install()
159158

160159
def update(self) -> None:
161-
if self.enabled:
160+
if self.pyproject.tool and self.pyproject.tool.cppython:
162161
if self.configuration.verbose:
163162
self._interface.print("CPPython: Updating...")
164163

165164
for generator in self._generators:
166165
generator.update()
167166

168167
def build(self) -> None:
169-
if self.enabled:
168+
if self.pyproject.tool and self.pyproject.tool.cppython:
170169
if self.configuration.verbose:
171170
self._interface.print("CPPython: Building...")
172171

pdm.lock

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ dynamic = ["version"]
1414
requires-python = ">=3.10"
1515

1616
dependencies = [
17-
"click>=8.0.3",
18-
"tomlkit>=0.10.0",
19-
"cppython-core>=0.1.4",
17+
"click>=8.1.2",
18+
"tomlkit>=0.10.1",
19+
"cppython-core>=0.2.1",
2020
"pydantic>=1.9.0",
2121
]
2222

@@ -40,7 +40,7 @@ test = [
4040
"pytest>=7.1.1",
4141
"pytest-cov>=3.0.0",
4242
"pytest-mock>=3.7.0",
43-
"pytest-cppython>=0.1.0",
43+
"pytest-cppython>=0.1.4",
4444
]
4545

4646
[project.scripts]

tests/unit/test_project.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def test_construction(self, mocker: MockerFixture):
2929

3030
interface_mock = mocker.MagicMock()
3131
configuration = ProjectConfiguration()
32-
Project(configuration, interface_mock, default_pyproject.dict())
32+
Project(configuration, interface_mock, default_pyproject.dict(by_alias=True))
33+
34+
def test_download(self):
35+
"""
36+
TODO
37+
"""
3338

3439

3540
class TestBuilder:
@@ -65,10 +70,10 @@ def test_generator_data_construction(self, mocker: MockerFixture):
6570

6671
model_type = builder.generate_model([generator_type])
6772

68-
project_data = default_pyproject.dict()
73+
project_data = default_pyproject.dict(by_alias=True)
6974

7075
mock_data = MockGeneratorData(check=True)
71-
project_data["tool"]["cppython"]["mock"] = mock_data.dict()
76+
project_data["tool"]["cppython"]["mock"] = mock_data.dict(by_alias=True)
7277
result = model_type(**project_data)
7378

7479
assert result.tool is not None

0 commit comments

Comments
 (0)