()
| 178 | |
| 179 | |
| 180 | def main() -> None: |
| 181 | parser = argparse.ArgumentParser(description=__doc__, add_help=False) |
| 182 | parser.add_argument("--build", action="store_true", help="Build the wheel") |
| 183 | parser.add_argument("--clean", action="store_true", help="Clean build folder") |
| 184 | parser.add_argument( |
| 185 | "--dev", |
| 186 | action="store_true", |
| 187 | help="Use editable pyodide-build from hardcoded path (Windows packing workaround)", |
| 188 | ) |
| 189 | args = parser.parse_args() |
| 190 | |
| 191 | if not args.build and not args.clean: |
| 192 | print(__doc__) |
| 193 | return |
| 194 | |
| 195 | if args.clean: |
| 196 | clean() |
| 197 | return |
| 198 | |
| 199 | start_time = time.time() |
| 200 | |
| 201 | WheelBuilder.extract_ifcopenshell_from_git(IFCOPENSHELL_DIR) |
| 202 | |
| 203 | print("Downloading and extracting _ifcopenshell_wrapper files...") |
| 204 | makefile = REPO_ROOT / "src" / "ifcopenshell-python" / "Makefile" |
| 205 | wheel_url = WheelBuilder.get_wheel_url(makefile) |
| 206 | so_file, py_file = WheelBuilder.download_and_extract_so(wheel_url, BUILD_DIR) |
| 207 | |
| 208 | Tools.create_symlink(IFCOPENSHELL_DIR / Path(so_file).name, so_file) |
| 209 | Tools.create_symlink(IFCOPENSHELL_DIR / Path(py_file).name, py_file) |
| 210 | |
| 211 | print("Installing pyodide-build...") |
| 212 | if args.dev: |
| 213 | Tools.run(["uv", "pip", "install", "-e", str(PYODIDE_BUILD)]) |
| 214 | else: |
| 215 | Tools.run(["uv", "pip", "install", "pyodide-build"]) |
| 216 | |
| 217 | print("Building with pyodide...") |
| 218 | # Use --no-isolation due to pyodide-build Windows support issues: |
| 219 | # symlink_unisolated_packages fails with missing `_sysconfigdata_$(CPYTHON_ABI_FLAGS)_emscripten_wasm32-emscripten.py`. |
| 220 | # Hardcode platform name since pyodide doesn't yet support overriding wheel tags on Windows. |
| 221 | # |
| 222 | # Use `LEGACY_PLATFORM` since pyodide 0.34.1 introduced new tag for wheels `pyemscripten`, |
| 223 | # which doesn't work with pyodide itself yet - https://github.com/pyodide/pyodide/issues/6177. |
| 224 | os.environ["USE_LEGACY_PLATFORM"] = "1" |
| 225 | Tools.run(["pyodide", "build", f"-C--build-option=--plat-name={WHEEL_PLATFORM_TAG}"]) |
| 226 | |
| 227 | elapsed = time.time() - start_time |
| 228 | print(f"\n✓ Done! ({elapsed:.1f}s)") |
| 229 | |
| 230 | |
| 231 | if __name__ == "__main__": |
no test coverage detected