Skip to content

Commit 86c0958

Browse files
committed
Install igl backend during setup for trimesh booleans
Add an install_igl_backend helper in setup.py that attempts to import igl and, if missing, installs it via pip so that trimesh has a libigl-backed boolean engine available. Call this helper unconditionally from DownloadAndBuildExt.run, warning but not failing the build if igl installation is not possible, to improve robustness of boolean operations across environments like macOS 3.9.
1 parent db6c9fb commit 86c0958

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

setup.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,31 @@ def build_0d(num_cores=None):
402402
print(f"svZeroDSolver executables have been installed into: {install_tmp_prefix}")
403403

404404

405+
def install_igl_backend():
406+
"""
407+
Ensure that the `igl` Python package is available so that trimesh
408+
has a robust boolean backend. If `igl` is already importable this
409+
is a no-op; otherwise we attempt to install it via pip.
410+
411+
Any installation failure is converted into a warning so that the
412+
overall svv build can still succeed, but boolean operations may
413+
lack the libigl-backed engine in that case.
414+
"""
415+
try:
416+
import igl # type: ignore # noqa: F401
417+
return
418+
except Exception:
419+
pass
420+
421+
print("Installing 'igl' for trimesh boolean backends...")
422+
try:
423+
subprocess.check_call([sys.executable, "-m", "pip", "install", "igl"])
424+
print("Finished installing 'igl'.")
425+
except Exception as e:
426+
print(f"Warning: failed to install 'igl' ({e}). "
427+
"Trimesh boolean operations may not have a robust backend.")
428+
429+
405430
class DownloadAndBuildExt(build_ext):
406431
def run(self):
407432
# Make external tool builds opt-in to avoid brittle installs and network fetches
@@ -420,6 +445,10 @@ def run(self):
420445
except Exception as e:
421446
print(f"Warning: svZeroDSolver build failed ({e}). Continuing without building solver.")
422447

448+
# Always ensure a trimesh/libigl backend is present for boolean operations,
449+
# but do not fail the build if installation is not possible.
450+
install_igl_backend()
451+
423452
# Always proceed to build Cython extensions
424453
super().run()
425454

0 commit comments

Comments
 (0)