1414 InputFile ,
1515 OutputFile ,
1616 BuildTarget ,
17- Module ,
17+ ExtensionModule ,
1818 makeplan ,
1919)
2020from .util import maybe_write_file
@@ -46,14 +46,14 @@ def _make_string(s: str):
4646
4747class VarCache :
4848 def __init__ (self ) -> None :
49- self .cache : T .Dict [T .Union [InputFile , OutputFile , BuildTarget , Module ], str ] = (
49+ self .cache : T .Dict [T .Union [InputFile , OutputFile , BuildTarget , ExtensionModule ], str ] = (
5050 {}
5151 )
5252
5353 # this might get annoying to debug, but for now this is easier...
5454 self .idx = 1
5555
56- def getvar (self , item : T .Union [InputFile , OutputFile , BuildTarget , Module ]) -> str :
56+ def getvar (self , item : T .Union [InputFile , OutputFile , BuildTarget , ExtensionModule ]) -> str :
5757 var = self .cache .get (item )
5858 if var is None :
5959
@@ -70,7 +70,7 @@ def getvar(self, item: T.Union[InputFile, OutputFile, BuildTarget, Module]) -> s
7070 # var = f"sw_out_{self.idx}"
7171 elif isinstance (item , BuildTarget ):
7272 var = f"_sw_target_{ self .idx } "
73- elif isinstance (item , Module ):
73+ elif isinstance (item , ExtensionModule ):
7474 var = f"{ item .name } _module"
7575 else :
7676 assert False
@@ -103,7 +103,7 @@ def _render_build_target(r: RenderBuffer, vc: VarCache, bt: BuildTarget):
103103 assert depfile is None , bt
104104 cmd .append ("'@DEPFILE@'" )
105105 depfile = _make_string (arg .name )
106- elif isinstance (arg , Module ):
106+ elif isinstance (arg , ExtensionModule ):
107107 cmd .append (f"'@INPUT{ len (tinput )} @'" )
108108 tinput .append (vc .getvar (arg ))
109109 else :
@@ -131,14 +131,14 @@ def _render_build_target(r: RenderBuffer, vc: VarCache, bt: BuildTarget):
131131 r .writeln (")" )
132132
133133
134- def _render_module_stage0 (r : RenderBuffer , vc : VarCache , m : Module ):
134+ def _render_module_stage0 (r : RenderBuffer , vc : VarCache , m : ExtensionModule ):
135135
136136 # variables generated here should be deterministic so that users can add
137137 # their own things to it, or use it directly
138138
139139 r .writeln (f"# { m .package_name } " )
140- r .writeln (f"{ m .name } _module_sources = []" )
141- r .writeln (f"{ m .name } _module_deps = [declare_dependency(" )
140+ r .writeln (f"{ m .name } _sources = []" )
141+ r .writeln (f"{ m .name } _deps = [declare_dependency(" )
142142 with r .indent ():
143143
144144 if m .sources :
@@ -156,23 +156,23 @@ def _render_module_stage0(r: RenderBuffer, vc: VarCache, m: Module):
156156 r .writeln (")]" )
157157
158158
159- def _render_module_stage1 (r : RenderBuffer , vc : VarCache , m : Module ):
159+ def _render_module_stage1 (r : RenderBuffer , vc : VarCache , m : ExtensionModule ):
160160
161161 # variables generated here should be deterministic so that users can
162162 # use it directly if they wish
163163
164164 subdir = _make_string (m .install_path .as_posix ())
165- package_name = _make_string (m .package_name )
165+ module_name = _make_string (m .package_name . split ( "." )[ - 1 ] )
166166 mvar = vc .getvar (m )
167167
168168 r .writeln (f"# { m .package_name } " )
169169 r .writeln (f"{ mvar } = sw_py.extension_module(" )
170170 with r .indent ():
171171 r .write_trim (
172172 f"""
173- '_ { m . name } ' ,
174- sources: [{ m .name } _module_sources ],
175- dependencies: [{ m .name } _module_deps ],
173+ { module_name } ,
174+ sources: [{ m .name } _sources ],
175+ dependencies: [{ m .name } _deps ],
176176 install: true,
177177 subdir: { subdir } ,
178178 """
@@ -196,12 +196,12 @@ def gen_meson(project_root: pathlib.Path) -> T.Tuple[str, str, T.List[Entrypoint
196196 # standard boilerplate here
197197 r0 .write_trim (
198198 """
199- # This file is automatically generated, DO NOT EDIT
200- #
201- # The generator's stable API includes variables that do not start with
202- # an underscore. Any variables with an underscore may change in the future
203- # without warning
204- #
199+ # This file is automatically generated, DO NOT EDIT
200+ #
201+ # The generator's stable API includes variables that do not start with
202+ # an underscore. Any variables with an underscore may change in the future
203+ # without warning
204+ #
205205
206206 sw_py = import('python').find_installation()
207207
@@ -228,7 +228,7 @@ def gen_meson(project_root: pathlib.Path) -> T.Tuple[str, str, T.List[Entrypoint
228228 # is simpler to generate
229229
230230 plan = makeplan (pathlib .Path (project_root ))
231- modules : T .List [Module ] = []
231+ modules : T .List [ExtensionModule ] = []
232232 pyi_targets : T .List [BuildTarget ] = []
233233
234234 for item in plan :
@@ -238,7 +238,7 @@ def gen_meson(project_root: pathlib.Path) -> T.Tuple[str, str, T.List[Entrypoint
238238 pyi_targets .append (item )
239239 else :
240240 _render_build_target (r0 , vc , item )
241- elif isinstance (item , Module ):
241+ elif isinstance (item , ExtensionModule ):
242242 # defer these to the end
243243 modules .append (item )
244244 elif isinstance (item , Entrypoint ):
@@ -250,9 +250,9 @@ def gen_meson(project_root: pathlib.Path) -> T.Tuple[str, str, T.List[Entrypoint
250250 r0 .writeln ()
251251 r0 .write_trim (
252252 """
253- #
254- # Module configurations
255- #
253+ #
254+ # Module configurations
255+ #
256256 """
257257 )
258258 r0 .writeln ()
0 commit comments