44
55from dataclasses import dataclass
66from importlib import metadata
7+ from pathlib import Path
78from typing import Any , Type , TypeVar
89from 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
0 commit comments