@@ -26,32 +26,18 @@ def wasmtime_script(context):
2626
2727script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd -P)
2828root=$(CDPATH= cd "$script_dir/.." && pwd -P)
29- wasm_file="$root/lib/python{ python_version (context )} /lib-wasm/python{ python_version (context , debug_ok = True )} .wasm"
29+ wasm_file="$root/lib/python{ context . python_version ()} /lib-wasm/python{ context . python_version (debug_ok = True )} .wasm"
3030
3131exec wasmtime run \\
3232 --argv0 "$wasm_file" \\
33- --config "$root/etc/python{ python_version (context )} /wasmtime.toml" \\
33+ --config "$root/etc/python{ context . python_version ()} /wasmtime.toml" \\
3434 --dir "/" \\
3535 "$wasm_file" "$@"
3636"""
3737
3838
39- def python_version (context , debug_ok = False ):
40- """Calculate the M.N part of Python's version.
41-
42- If *debug_ok* is True, then "d" is appended as appropriate.
43- """
44- details = context .wasi_build_details
45- major = details ["language" ]["version_info" ]["major" ]
46- minor = details ["language" ]["version_info" ]["minor" ]
47- version = f"{ major } .{ minor } "
48- if debug_ok and context .is_debug :
49- version += "d"
50- return version
51-
52-
5339def lib_python (context ):
54- return pathlib .PurePath ("lib" ) / f"python{ python_version (context )} "
40+ return pathlib .PurePath ("lib" ) / f"python{ context . python_version ()} "
5541
5642
5743def license_file (context ):
@@ -101,12 +87,12 @@ def pkgconfig_files(context):
10187 pkgconfig = pathlib .PurePath ("lib" ) / "pkgconfig"
10288 return [
10389 (
104- pkgconfig / f"python-{ python_version (context , debug_ok = True )} .pc" ,
90+ pkgconfig / f"python-{ context . python_version (debug_ok = True )} .pc" ,
10591 misc_dir / "python.pc" ,
10692 ),
10793 (
10894 pkgconfig
109- / f"python-{ python_version (context , debug_ok = True )} -embed.pc" ,
95+ / f"python-{ context . python_version (debug_ok = True )} -embed.pc" ,
11096 misc_dir / "python-embed.pc" ,
11197 ),
11298 ]
@@ -127,11 +113,11 @@ def pkgconfig_symlinks(pkgconfig_files, context):
127113 paths += [
128114 (
129115 embed_path .parent
130- / f"python-{ python_version (context )} -embed.pc" ,
116+ / f"python-{ context . python_version ()} -embed.pc" ,
131117 embed_path ,
132118 ),
133119 (
134- plain_path .parent / f"python-{ python_version (context )} .pc" ,
120+ plain_path .parent / f"python-{ context . python_version ()} .pc" ,
135121 plain_path ,
136122 ),
137123 ]
@@ -143,7 +129,7 @@ def pyconfig_file(context):
143129 """Have <build>/pyconfig.h end up in include/pythonXYd?/pyconfig.h."""
144130 return (
145131 pathlib .PurePath ("include" )
146- / f"python{ python_version (context , debug_ok = True )} "
132+ / f"python{ context . python_version (debug_ok = True )} "
147133 / "pyconfig.h" ,
148134 context .wasi_build_path / "pyconfig.h" ,
149135 )
@@ -158,7 +144,7 @@ def header_files(context):
158144 file_path = pathlib .Path (root ) / filename
159145 details = (
160146 pathlib .PurePath ("include" )
161- / f"python{ python_version (context , debug_ok = True )} "
147+ / f"python{ context . python_version (debug_ok = True )} "
162148 / file_path .relative_to (include_dir ),
163149 file_path ,
164150 )
@@ -171,7 +157,7 @@ def man_file(context):
171157 man_dir = pathlib .PurePath ("share" , "man" , "man1" )
172158 man_file = context .checkout / "Misc" / "python.man"
173159 return (
174- man_dir / f"python{ python_version (context )} .1" ,
160+ man_dir / f"python{ context . python_version ()} .1" ,
175161 man_file ,
176162 )
177163
@@ -187,7 +173,7 @@ def wasmtime_config_file(context):
187173 config = context .checkout / "Platforms" / "WASI" / "wasmtime.toml"
188174 return (
189175 pathlib .PurePath ("etc" )
190- / f"python{ python_version (context )} "
176+ / f"python{ context . python_version ()} "
191177 / "wasmtime.toml" ,
192178 config ,
193179 )
@@ -198,17 +184,15 @@ def wasm_file(context):
198184 return (
199185 lib_python (context )
200186 / "lib-wasm"
201- / f"python{ python_version (context , debug_ok = True )} .wasm" ,
187+ / f"python{ context . python_version (debug_ok = True )} .wasm" ,
202188 context .wasi_build_path / "python.wasm" ,
203189 )
204190
205191
206- def python_wasmtime_script (base , context ):
192+ def python_wasmtime_script (context ):
207193 """Create bin/pythonN.Md?.wasmtime."""
208194 script = wasmtime_script (context )
209- path = (
210- base / f"bin/python{ python_version (context , debug_ok = True )} .wasmtime"
211- )
195+ path = context .dist_python_interpreter
212196 path .parent .mkdir (parents = True , exist_ok = True )
213197 with open (path , "w" ) as f :
214198 f .write (script )
@@ -221,15 +205,15 @@ def python_wasmtime_symlink(path, context):
221205 """Symlink bin/pythonN.Md?.wasmtime.
222206
223207 - bin/pythonN.M.wasmtime (if debug build)
224- - bin/pythonN.wasmtime (if debug build)
208+ - bin/pythonN.wasmtime
225209 """
226210 symlinks = [
227211 path .parent / f"python{ context .wasi_build_version ['major' ]} .wasmtime"
228212 ]
229213 if context .is_debug :
230214 # The file already has the debug name, so the missing symlink is the non-debug name.
231215 symlinks .append (
232- path .parent / f"python{ python_version (context )} .wasmtime"
216+ path .parent / f"python{ context . python_version ()} .wasmtime"
233217 )
234218
235219 return [(symlink , path ) for symlink in symlinks ]
@@ -239,7 +223,7 @@ def config_file(context):
239223 """Have Misc/config.sh end up at bin/pythonN.Md?.config."""
240224 return (
241225 pathlib .PurePath ("bin" )
242- / f"python{ python_version (context , debug_ok = True )} -config" ,
226+ / f"python{ context . python_version (debug_ok = True )} -config" ,
243227 context .wasi_build_path / "Misc" / "python-config.sh" ,
244228 )
245229
@@ -258,7 +242,7 @@ def config_symlink(config_path, context):
258242 if context .is_debug :
259243 # The file already has the debug name, so the missing symlink is the non-debug name.
260244 symlinks .append (
261- config_path .parent / f"python{ python_version (context )} -config"
245+ config_path .parent / f"python{ context . python_version ()} -config"
262246 )
263247
264248 return [(symlink , config_path ) for symlink in symlinks ]
@@ -281,8 +265,8 @@ def symlink_files(files, base):
281265
282266
283267def gather (context ):
284- py_version = python_version (context )
285- py_d_version = python_version (context , debug_ok = True )
268+ py_version = context . python_version ()
269+ py_d_version = context . python_version (debug_ok = True )
286270
287271 dist = context .dist_path
288272 if dist .exists ():
@@ -300,7 +284,7 @@ def gather(context):
300284 symlink_files (config_symlink (config_location [0 ], context ), base )
301285
302286 _shared .log ("📄" , f"python{ py_d_version } .wasmtime" , spacing = indent * 3 )
303- script_path = python_wasmtime_script (base , context )
287+ script_path = python_wasmtime_script (context )
304288 symlink_files (python_wasmtime_symlink (script_path , context ), base )
305289
306290 _shared .log ("📁" , "etc/" , spacing = indent * 2 )
@@ -353,8 +337,7 @@ def gather(context):
353337
354338
355339def archive (context ):
356- file_name = f"{ context .archive_stem } .tar.xz"
357- file_path = context .dist_path / file_name
340+ file_path = context .archive_path
358341 if file_path .exists ():
359342 _shared .log ("🧹" , f"Deleting { file_path } ..." )
360343 file_path .unlink ()
0 commit comments