build-all.py - accomodate pyodide build system automatically

as it's the main way to build the wasm package
This commit is contained in:
Andrej730
2025-10-20 11:45:49 +05:00
parent aee8cbe479
commit f8bb04eae3
3 changed files with 10 additions and 16 deletions
+9 -12
View File
@@ -269,9 +269,11 @@ if platform.system() == "Darwin":
IFCOS_NUM_BUILD_PROCS = os.getenv("IFCOS_NUM_BUILD_PROCS", multiprocessing.cpu_count() + 1)
CMAKE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "cmake"))
SCRIPT_PATH = Path(__file__).parent
REPO_PATH = SCRIPT_PATH.parent
CMAKE_DIR = (REPO_PATH / "cmake").resolve().__str__()
build_dir = os.environ.get("BUILD_DIR", os.path.join(os.path.dirname(__file__), "..", "build"))
build_dir = os.environ.get("BUILD_DIR", (REPO_PATH / "build").__str__())
if WASM:
@@ -716,7 +718,7 @@ def build_dependency(
if isinstance(patch, str):
patch = [patch]
for p in patch:
patch_abs = os.path.abspath(os.path.join(os.path.dirname(__file__), p))
patch_abs = (SCRIPT_PATH / p).absolute().__str__()
if os.path.exists(patch_abs):
try:
run(["patch", "-p1", "--batch", "--forward", "-i", patch_abs], cwd=extract_dir)
@@ -1504,15 +1506,8 @@ if "IfcOpenShell-Python" in targets:
+ get_cmake_args_prefix_path(prefix_paths)
+ [
*([f"-DPYTHON_EXECUTABLE={python_executable}"] if python_executable else []),
# *([f"-DPYTHON_MODULE_INSTALL_DIR={os.environ['PYTHONPATH']}/ifcopenshell"] if "wasm" in flags else []),
*(
[
"-DPYTHON_MODULE_INSTALL_DIR="
+ os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "package"))
]
if "wasm" in flags
else []
),
# Needed because pyodide is expecting setup.py to be in the root.
*([f"-DPYTHON_MODULE_INSTALL_DIR={REPO_PATH}"] * WASM),
f"-DPYTHON_LIBRARY={python_library}",
f"-DPYTHON_INCLUDE_DIR={python_include}",
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/ifcopenshell/tmp",
@@ -1557,6 +1552,8 @@ if "IfcOpenShell-Python" in targets:
os.environ["PYTHONINCLUDE"],
None,
)
# Copy setup.py where pyodide build system expects it.
shutil.copy(REPO_PATH / "pyodide" / "setup.py", REPO_PATH)
elif USE_CURRENT_PYTHON_VERSION:
python_info = sysconfig.get_paths()
+1 -2
View File
@@ -13,7 +13,7 @@ There are two ways to build pyodide ifcopenshell Python wrapper wheel.
- build ifcopenshell and its dependencies
- note that rerunning `pyodide build-recipes` will remove previous build folder and rebuild all dependencies.
The way to avoid it, if build fails, is to use `pyodide build-recipes-no-deps ifcopenshell --continue` instead.
- run `pyodide/setup.py` in `IfcOpenShell` root, producing a wheel in `IfcOpenShell/dist`
- run `setup.py` in `IfcOpenShell` root, producing a wheel in `IfcOpenShell/dist`
- copy that wheel to `packages/ifcopenshell/dist`
- `--install` it to current build envrionment
- copy the wheel next to `dist` folder (in root directory, next to `packages`)
@@ -29,6 +29,5 @@ since it's pure cmake without any additional moving parts.
- setup debug build environment using `source pyodide/debug_build_env.sh /path/to/pyodide_root`
- run `python nix/build-all.py -wasm -py-313` in `IfcOpenShell`
- it will produce Python package in `IfcOpenShell/ifcopenshell`
- move `IfcOpenShell/pyodide/setup.py` to `IfcOpenShell` root
- run `pyodide build`
- it will produce a wheel in `IfcOpenShell/dist`
-2
View File
@@ -9,8 +9,6 @@ source:
build:
script: |
BUILD_CFG=Release python nix/build-all.py -v --wasm --py313
mv package/ifcopenshell .
cp pyodide/setup.py .
about:
home: http://ifcopenshell.org