Skip to content

Conversation

@killerapp
Copy link

Summary

This PR adds support for building Habitat-Sim using UV/pip-based workflows on WSL2, eliminating the conda dependency. It includes build environment variables, WSL2 GPU compatibility fixes, and comprehensive documentation.

Key Changes

  1. Build Environment Variables (setup.py)

    • HSIM_NO_SUBMODULE_UPDATE=1: Skip git submodule updates during build (useful for pre-patched environments)
    • HSIM_SKIP_CMAKE_BUILD=1: Reuse existing CMake build artifacts (accelerates iterative builds)
  2. WSL2 GPU Compatibility (src/esp/gfx/WindowlessContext.cpp)

    • HSIM_DISABLE_CUDA_DEVICE=1: Bypass CUDA device enumeration on WSL2
    • Enables D3D12 backend rendering when CUDA device access is unavailable/incompatible
  3. Comprehensive Documentation

    • UV_WSL2_BUILD.md: Complete guide for building with UV on WSL2
      • System dependencies installation
      • OpenEXR patching instructions
      • Build commands and troubleshooting
    • OPENEXR_PATCHES.md: Required <cstdint> header fixes for OpenEXR submodule
      • Patches for modern C++ compiler compatibility
  4. UV Workflow Support

    • .gitignore: Added build-headless/ directory
    • uv.lock: Python dependency lock file for reproducible builds

Why This PR?

Problem: Building Habitat-Sim traditionally requires conda, which can be heavyweight and incompatible with modern Python workflows using UV or pip.

Solution: This PR enables building wheels directly with UV/pip on WSL2 by:

  • Providing build controls to skip submodule updates and reuse builds
  • Working around WSL2's CUDA enumeration limitations
  • Documenting required OpenEXR patches for modern compilers

Use Cases

  • CI/CD pipelines using pip/UV instead of conda
  • WSL2 developers needing D3D12 rendering without CUDA
  • Iterative development with cached CMake builds
  • Reproducible environments via uv.lock

Test Plan

  • Verify build succeeds on WSL2 Ubuntu with UV workflow
  • Confirm HSIM_DISABLE_CUDA_DEVICE=1 allows rendering on WSL2
  • Test HSIM_NO_SUBMODULE_UPDATE=1 skips submodule operations
  • Test HSIM_SKIP_CMAKE_BUILD=1 reuses existing builds
  • Validate OpenEXR patches compile with modern GCC/Clang
  • Ensure uv.lock produces reproducible environments
  • Verify conda builds remain unaffected

🤖 Generated with Claude Code

Vaskin and others added 5 commits October 3, 2025 00:44
Add support for HSIM_NO_SUBMODULE_UPDATE and HSIM_SKIP_CMAKE_BUILD
environment variables to allow more flexible build workflows.

HSIM_NO_SUBMODULE_UPDATE=1: Skip git submodule update step, useful
when submodules have local patches or custom commits.

HSIM_SKIP_CMAKE_BUILD=1: Reuse existing build artifacts when packaging,
avoiding full rebuild when creating wheels from already-built binaries.

This is particularly useful for:
- UV-based development workflows without conda
- Creating wheels from manually-configured CMake builds
- Preserving local modifications to submodules

Related to UV/pip installation support for WSL2 and Linux environments.
Add HSIM_DISABLE_CUDA_DEVICE environment variable to bypass CUDA device
enumeration in EGL context initialization. This is essential for WSL2
environments where CUDA device detection can fail or cause issues with
D3D12-based GPU rendering.

When HSIM_DISABLE_CUDA_DEVICE is set to any value, the EGL context will
skip setCudaDevice() and use the default device, allowing proper
initialization with Mesa D3D12 backend on WSL2.

Usage:
  HSIM_DISABLE_CUDA_DEVICE=1 python your_script.py

This enables GPU-accelerated rendering on WSL2 with NVIDIA drivers
via the D3D12 backend (GALLIUM_DRIVER=d3d12).
Add documentation for the <cstdint> include patches required in the
OpenEXR submodule to compile with modern C++ compilers.

The patches cannot be committed directly since they're in a submodule,
but this document provides instructions for applying them manually.
Add detailed documentation for building Habitat-Sim wheels for
UV/pip workflows on WSL2 with GPU support.

Includes:
- Complete build instructions from scratch
- Environment variable reference
- WSL2 GPU setup and usage
- Integration with TBP Monty project
- Known limitations and compatibility notes
- Add uv.lock for reproducible Python dependencies
- Ignore build-headless/ directory in .gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@meta-cla
Copy link

meta-cla bot commented Oct 3, 2025

Hi @killerapp!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Vaskin and others added 10 commits October 3, 2025 01:55
Changes:
- Renamed package to 'habitat-sim-uv-wheels-experimental' for PyPI
- Added PyPI-compatible metadata (license, URLs, description)
- Configured setup.cfg to avoid license-file metadata issues
- Added CLAUDE.local.md documenting TBP Monty integration

Published wheel: https://pypi.org/project/habitat-sim-uv-wheels-experimental/

This allows pip/UV users to install habitat-sim without conda:
  pip install habitat-sim-uv-wheels-experimental

Built for TBP Monty (Thousand Brains Project) sensorimotor learning.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
… set

- Change version to 0.2.2a1 (alpha release)
- Fix setup.py to copy compiled .so files to wheel when skipping CMake build
- Add GitHub Actions workflow for PyPI publishing
- Wheel now includes habitat_sim_bindings.cpython-38-x86_64-linux-gnu.so (442MB)

This fixes the missing bindings issue where wheels built with HSIM_SKIP_CMAKE_BUILD=1
only contained Python source files. The compiled C++ extension is now properly
included in the package.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Create automated patch script to fix cstdint includes in OpenEXR
- Update workflow to apply patches after checkout
- Fixes compilation errors with modern C++ compilers (GCC 13+)
- Cache entire build directory with compiled dependencies
- Cache key based on source file hashes for automatic invalidation
- Excludes wheel build artifacts (bdist, lib dirs)
- Reduces build time from ~15min to ~2min on cache hits
The full CMake build happens in a previous step with python setup.py.
The wheel build step should always reuse those artifacts with HSIM_SKIP_CMAKE_BUILD=1
to avoid CMake version compatibility issues with uv's isolated build environment.
- Add custom bdist_wheel class to generate manylinux_2_31_x86_64 tag
- PyPI requires manylinux tags for Linux wheels, not generic linux_x86_64
- Compatible with Ubuntu 20.04+ (glibc 2.31+)
- Copy .so files to source tree before building wheel
- Use setup.py bdist_wheel instead of uv build (avoids isolated env)
- Add _ext directory to MANIFEST.in
- Fixes 168KB wheel missing 442MB compiled bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant