|
24 | 24 | from functools import lru_cache |
25 | 25 | from typing import TYPE_CHECKING, Any |
26 | 26 |
|
27 | | -import cpuinfo |
28 | 27 | import numpy as np |
29 | 28 | import platformdirs |
30 | 29 |
|
31 | 30 | import blosc2 |
32 | 31 | from blosc2 import blosc2_ext |
33 | 32 |
|
| 33 | +if not blosc2.IS_WASM: |
| 34 | + import cpuinfo |
| 35 | + |
34 | 36 | if TYPE_CHECKING: |
35 | 37 | from collections.abc import Callable |
36 | 38 |
|
@@ -1119,13 +1121,19 @@ def print_versions(): |
1119 | 1121 | for clib in sorted(clib_versions.keys()): |
1120 | 1122 | print(f" {clib}: {clib_versions[clib]}") |
1121 | 1123 | print(f"NumPy version: {np.__version__}") |
| 1124 | + if not blosc2.IS_WASM: |
| 1125 | + import numexpr |
| 1126 | + |
| 1127 | + print(f"numexpr version: {numexpr.__version__}") |
1122 | 1128 | print(f"Python version: {sys.version}") |
1123 | 1129 | (sysname, _nodename, release, version, machine, processor) = platform.uname() |
1124 | 1130 | print(f"Platform: {sysname}-{release}-{machine} ({version})") |
1125 | 1131 | if sysname == "Linux": |
1126 | 1132 | distro = os_release_pretty_name() |
1127 | 1133 | if distro: |
1128 | 1134 | print(f"Linux dist: {distro}") |
| 1135 | + if blosc2.IS_WASM: |
| 1136 | + processor = "wasm32" |
1129 | 1137 | if not processor: |
1130 | 1138 | processor = "not recognized" |
1131 | 1139 | print(f"Processor: {processor}") |
@@ -1202,6 +1210,17 @@ def linux_cache_size(cache_level: int, default_size: int) -> int: |
1202 | 1210 |
|
1203 | 1211 |
|
1204 | 1212 | def _get_cpu_info(): |
| 1213 | + if blosc2.IS_WASM: |
| 1214 | + # Emscripten/wasm32 does not have access to CPU information. |
| 1215 | + # Populate it with some reasonable defaults. |
| 1216 | + return { |
| 1217 | + "brand": "Emscripten", |
| 1218 | + "arch": "wasm32", |
| 1219 | + "count": 1, |
| 1220 | + "l1_data_cache_size": 32 * 1024, |
| 1221 | + "l2_cache_size": 256 * 1024, |
| 1222 | + "l3_cache_size": 1024 * 1024, |
| 1223 | + } |
1205 | 1224 | cpu_info = cpuinfo.get_cpu_info() |
1206 | 1225 | # cpuinfo does not correctly retrieve the cache sizes for Apple Silicon, so do it manually |
1207 | 1226 | if platform.system() == "Darwin": |
|
0 commit comments