()
| 189 | |
| 190 | |
| 191 | def main() -> None: |
| 192 | args = parser.parse_args() |
| 193 | |
| 194 | relative_prefix = args.prefix.relative_to(pathlib.Path("/")) |
| 195 | args.srcdir = SRCDIR |
| 196 | args.srcdir_lib = SRCDIR_LIB |
| 197 | args.wasm_root = args.buildroot / relative_prefix |
| 198 | args.wasm_stdlib = args.wasm_root / WASM_STDLIB |
| 199 | args.wasm_dynload = args.wasm_root / WASM_DYNLOAD |
| 200 | |
| 201 | # bpo-17004: zipimport supports only zlib compression. |
| 202 | # Emscripten ZIP_STORED + -sLZ4=1 linker flags results in larger file. |
| 203 | args.compression = zipfile.ZIP_DEFLATED |
| 204 | args.compresslevel = 9 |
| 205 | |
| 206 | args.builddir = get_builddir(args) |
| 207 | args.sysconfig_data = get_sysconfigdata(args) |
| 208 | if not args.sysconfig_data.is_file(): |
| 209 | raise ValueError(f"sysconfigdata file {args.sysconfig_data} missing.") |
| 210 | |
| 211 | extmods = detect_extension_modules(args) |
| 212 | omit_files = list(OMIT_FILES) |
| 213 | if sysconfig.get_platform().startswith("emscripten"): |
| 214 | omit_files.extend(OMIT_NETWORKING_FILES) |
| 215 | for modname, modfiles in OMIT_MODULE_FILES.items(): |
| 216 | if not extmods.get(modname): |
| 217 | omit_files.extend(modfiles) |
| 218 | |
| 219 | args.omit_files_absolute = { |
| 220 | (args.srcdir_lib / name).resolve() for name in omit_files |
| 221 | } |
| 222 | |
| 223 | # Empty, unused directory for dynamic libs, but required for site initialization. |
| 224 | args.wasm_dynload.mkdir(parents=True, exist_ok=True) |
| 225 | marker = args.wasm_dynload / ".empty" |
| 226 | marker.touch() |
| 227 | # The rest of stdlib that's useful in a WASM context. |
| 228 | create_stdlib_zip(args) |
| 229 | size = round(args.output.stat().st_size / 1024**2, 2) |
| 230 | parser.exit(0, f"Created {args.output} ({size} MiB)\n") |
| 231 | |
| 232 | |
| 233 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…