4
4
5
5
from dataclasses import dataclass
6
6
from importlib import metadata
7
+ from pathlib import Path
7
8
from typing import Any , Type , TypeVar
8
9
from xmlrpc .client import Boolean
9
10
@@ -98,7 +99,6 @@ def __init__(
98
99
self , configuration : ProjectConfiguration , interface : Interface , pyproject_data : dict [str , Any ]
99
100
) -> None :
100
101
101
- self .enabled = False
102
102
self .configuration = configuration
103
103
104
104
if self .configuration .verbose :
@@ -113,60 +113,59 @@ def __init__(
113
113
return
114
114
115
115
extended_pyproject_type = builder .generate_model (plugins )
116
- pyproject = extended_pyproject_type (** pyproject_data )
116
+ self . pyproject = extended_pyproject_type (** pyproject_data )
117
117
118
- if pyproject .tool is None :
118
+ if self . pyproject .tool is None :
119
119
if self .configuration .verbose :
120
120
interface .print ("Table [tool] is not defined" )
121
121
return
122
122
123
- if pyproject .tool .cppython is None :
123
+ if self . pyproject .tool .cppython is None :
124
124
if self .configuration .verbose :
125
125
interface .print ("Table [tool.cppython] is not defined" )
126
126
return
127
127
128
- self .enabled = True
129
-
130
128
self ._interface = interface
131
- self ._generators = builder .create_generators (plugins , pyproject )
129
+ self ._generators = builder .create_generators (plugins , self . pyproject )
132
130
133
131
if self .configuration .verbose :
134
132
interface .print ("CPPython project initialized" )
135
133
136
- def download (self ):
134
+ def download (self , path : Path ):
137
135
"""
138
136
Download the generator tooling if required
139
137
"""
138
+
140
139
for generator in self ._generators :
141
140
142
- if not generator .generator_downloaded ():
141
+ if not generator .generator_downloaded (path ):
143
142
self ._interface .print (f"Downloading the { generator .name ()} tool" )
144
143
145
144
# TODO: Make async with progress bar
146
- generator .download_generator ()
145
+ generator .download_generator (path )
147
146
self ._interface .print ("Download complete" )
148
147
149
148
# API Contract
150
149
151
150
def install (self ) -> None :
152
- if self .enabled :
151
+ if self .pyproject . tool and self . pyproject . tool . cppython :
153
152
if self .configuration .verbose :
154
153
self ._interface .print ("CPPython: Installing..." )
155
- self .download ()
154
+ self .download (self . pyproject . tool . cppython . install_path )
156
155
157
156
for generator in self ._generators :
158
157
generator .install ()
159
158
160
159
def update (self ) -> None :
161
- if self .enabled :
160
+ if self .pyproject . tool and self . pyproject . tool . cppython :
162
161
if self .configuration .verbose :
163
162
self ._interface .print ("CPPython: Updating..." )
164
163
165
164
for generator in self ._generators :
166
165
generator .update ()
167
166
168
167
def build (self ) -> None :
169
- if self .enabled :
168
+ if self .pyproject . tool and self . pyproject . tool . cppython :
170
169
if self .configuration .verbose :
171
170
self ._interface .print ("CPPython: Building..." )
172
171
0 commit comments