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