24
24
import shutil
25
25
import subprocess
26
26
import sysconfig
27
- from typing import Callable , List , Union # for Python 3.8
27
+ # for Python 3.8
28
+ from typing import Any , Dict , Callable , Iterable , List , Optional , Union
28
29
29
30
SRCDIR = pathlib .Path (__file__ ).parent .parent .parent .absolute ()
30
31
WASMTOOLS = SRCDIR / "Tools" / "wasm"
77
78
"""
78
79
79
80
80
- def get_emscripten_root (emconfig : pathlib .Path = EM_CONFIG ) -> pathlib .Path :
81
+ def get_emscripten_root (emconfig : pathlib .Path = EM_CONFIG ) -> pathlib .PurePath :
81
82
"""Parse EM_CONFIG file and lookup EMSCRIPTEN_ROOT
82
83
83
84
The ".emscripten" config file is a Python snippet that uses "EM_CONFIG"
@@ -89,7 +90,7 @@ def get_emscripten_root(emconfig: pathlib.Path = EM_CONFIG) -> pathlib.Path:
89
90
with open (emconfig , encoding = "utf-8" ) as f :
90
91
code = f .read ()
91
92
# EM_CONFIG file is a Python snippet
92
- local = {}
93
+ local : Dict [ str , Any ] = {}
93
94
exec (code , globals (), local )
94
95
return pathlib .Path (local ["EMSCRIPTEN_ROOT" ])
95
96
@@ -127,9 +128,9 @@ class Platform:
127
128
128
129
name : str
129
130
pythonexe : str
130
- config_site : pathlib .Path
131
- configure_wrapper : pathlib .Path
132
- make_wrapper : pathlib .Path
131
+ config_site : Optional [ pathlib .PurePath ]
132
+ configure_wrapper : Optional [ pathlib .PurePath ]
133
+ make_wrapper : Optional [ pathlib .PurePath ]
133
134
environ : dict
134
135
check : Callable [[], None ]
135
136
@@ -144,12 +145,13 @@ def _check_clean_src():
144
145
]
145
146
for candidate in candidates :
146
147
if candidate .exists ():
147
- raise DirtySourceDirectory (candidate , CLEAN_SRCDIR )
148
+ raise DirtySourceDirectory (os . fspath ( candidate ) , CLEAN_SRCDIR )
148
149
149
150
150
151
NATIVE = Platform (
151
152
"native" ,
152
- pythonexe = sysconfig .get_config_var ("BUILDPYTHON" ), # macOS has python.exe
153
+ # macOS has python.exe
154
+ pythonexe = sysconfig .get_config_var ("BUILDPYTHON" ) or "python" ,
153
155
config_site = None ,
154
156
configure_wrapper = None ,
155
157
make_wrapper = None ,
@@ -164,17 +166,17 @@ def _check_emscripten():
164
166
# sanity check
165
167
emconfigure = EMSCRIPTEN .configure_wrapper
166
168
if not emconfigure .exists ():
167
- raise MissingDependency (emconfigure , INSTALL_EMSDK )
169
+ raise MissingDependency (os . fspath ( emconfigure ) , INSTALL_EMSDK )
168
170
# version check
169
171
version_txt = EMSCRIPTEN_ROOT / "emscripten-version.txt"
170
172
if not version_txt .exists ():
171
- raise MissingDependency (version_txt , INSTALL_EMSDK )
173
+ raise MissingDependency (os . fspath ( version_txt ) , INSTALL_EMSDK )
172
174
with open (version_txt ) as f :
173
175
version = f .read ().strip ().strip ('"' )
174
176
version_tuple = tuple (int (v ) for v in version .split ("." ))
175
177
if version_tuple < EMSDK_MIN_VERSION :
176
178
raise MissingDependency (
177
- version_txt ,
179
+ os . fspath ( version_txt ) ,
178
180
f"Emscripten SDK { version } in '{ EMSCRIPTEN_ROOT } ' is older than "
179
181
"minimum required version "
180
182
f"{ '.' .join (str (v ) for v in EMSDK_MIN_VERSION )} ." ,
@@ -196,7 +198,7 @@ def _check_emscripten():
196
198
def _check_wasi ():
197
199
wasm_ld = WASI_SDK_PATH / "bin" / "wasm-ld"
198
200
if not wasm_ld .exists ():
199
- raise MissingDependency (wasm_ld , INSTALL_WASI_SDK )
201
+ raise MissingDependency (os . fspath ( wasm_ld ) , INSTALL_WASI_SDK )
200
202
wasmtime = shutil .which ("wasmtime" )
201
203
if wasmtime is None :
202
204
raise MissingDependency ("wasmtime" , INSTALL_WASMTIME )
0 commit comments