Skip to content

Separate pybind module from libOpen3D shared library in Python wheels#7355

Draft
Copilot wants to merge 15 commits intomainfrom
copilot/separate-pybind-and-libopen3d
Draft

Separate pybind module from libOpen3D shared library in Python wheels#7355
Copilot wants to merge 15 commits intomainfrom
copilot/separate-pybind-and-libopen3d

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Type

  • New feature (non-breaking change which adds functionality).

Motivation and Context

Python wheels currently embed all C++ code into the pybind module via static linking. This PR separates them: pybind module now dynamically links to libOpen3D.so/dylib/dll, both packaged in the wheel. This provides a more modular architecture allowing pybind and libOpen3D to be updated independently.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test results (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Core build logic:

  • Change default value of BUILD_SHARED_LIBS from OFF to ON in CMakeLists.txt
  • This allows users to still build with static libOpen3D by explicitly setting -DBUILD_SHARED_LIBS=OFF if needed
  • Existing package infrastructure already copies and bundles both files correctly

CI/Docker updates:

  • Remove BUILD_SHARED_LIBS=OFF from:
    • docker/Dockerfile.wheel
    • util/ci_utils.sh (build_pip_package function)
    • .github/workflows/windows.yml (wheel build)
  • Remove STATIC_WINDOWS_RUNTIME=ON from Windows wheel build (shared libs require DLL runtime)

macOS fix:

  • Remove NOT BUILD_SHARED_LIBS condition from OpenMP library packaging (previously unhandled)

Branch updates:

  • Updated branch from main, incorporating 8 new commits including NumPy array performance improvements, Filament/GLFW upgrades, VoxelGrid features, and various bug fixes

Result:

By default, wheels now contain:

open3d/
├── pybind.so           # Python bindings (small)
└── libOpen3D.so.X.Y    # C++ library (large)

Instead of:

open3d/
└── pybind.so           # Everything statically linked (large)

Users can still build Python bindings with static libOpen3D by explicitly setting BUILD_SHARED_LIBS=OFF if needed for custom builds.

User code unchanged: import open3d works identically.

Original prompt

Task:
Open3D python bindings are created as a single DLL (named pybind) that contains both the compiled C++ code and the python binding code. Separate this, so that pybind DLL instead always loads libOpen3D.so DLL. Propagate this change to docker files and CI for wheel building.

Agent instructions for Open3D:
Open3D contains 3D data processing and machine learning code that runs on CPU, CUDA (Nvidia) GPUs and SYCL / OneAPI (Intel) GPUs.
All new or updated functionality should:

  • Be written in C++17, CUDA and SYCL2020 and exposed through Python bindings (folder cpp/pybind). CUDA and SYCL support is optional.
  • Have unit tests (C++ unit tests in cpp/tests folder and non-trivial Python features in python/tests folder).
  • Have C++ (Doxygen) docs in the C++ header files and Python (Sphinx Google style rst format) docs in the pybind files. Include simple usage examples in the docs as appropriate.
  • Run clang-format and yapf to format code. C++ code must not produce compiler (g++ / clang++) warnings and any linting issues (e.g. clang-tidy reporting missing include header) should be resolved if feasible.
    For CI and dependencies:
  • CUDA and OneAPI API version should be compatible with the PyTorch versions (python/requirements*.txt).
  • When updating dependencies, prefer the highest available version that is compatible with other dependencies and Open3D usage.
  • Open3D builds must run on the oldest supported Ubuntu LTS (e.g. Ubuntu 20.04 before April 2025), and Windows and macOS versions that are atleast 5 years old. Similarly, 5 year old Python versions are supported (aligning with Pythin official support).

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Oct 31, 2025
@update-docs
Copy link

update-docs bot commented Oct 31, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

Copilot AI and others added 4 commits October 31, 2025 23:53
- Modified CMakeLists.txt to automatically set BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON
- Updated Dockerfile.wheel to remove explicit BUILD_SHARED_LIBS=OFF
- Updated Windows workflow to remove explicit BUILD_SHARED_LIBS=OFF for wheel builds
- Updated ci_utils.sh to remove BUILD_SHARED_LIBS=OFF from pip package builds
This ensures pybind module dynamically links to libOpen3D.so instead of statically embedding it

Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com>
- Removed the NOT BUILD_SHARED_LIBS condition from OpenMP library packaging
- Now packages libomp for macOS regardless of build type since Python builds always use shared libs

Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com>
- Removed explicit STATIC_WINDOWS_RUNTIME=ON from Windows wheel workflow
- When BUILD_SHARED_LIBS=ON (now automatic for Python), STATIC_WINDOWS_RUNTIME defaults to OFF
- Shared libraries should use DLL runtime (/MD) instead of static runtime (/MT)

Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com>
- Added conditional message only when BUILD_SHARED_LIBS was OFF
- Clarified why shared libraries are required for Python module

Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com>
Copilot AI changed the title [WIP] Separate pybind DLL from libOpen3D loading Separate pybind module from libOpen3D shared library in Python wheels Nov 1, 2025
Copilot AI requested a review from ssheorey November 1, 2025 00:03
@ssheorey
Copy link
Member

ssheorey commented Nov 1, 2025

@copilot Do not change CMakeLists.txt, i.e. allow the option of building python bindings with a static libOpen3D. Instead only change CI, build scripts and docker files to build Python wheels with a shared libOpen3D. However, update the default value of BUILD_SHARED_LIBS=ON, since BUILD_PYTHON_MODULE=ON by default.

- Reverted the CMakeLists.txt logic that forced BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON
- Changed the default value of BUILD_SHARED_LIBS from OFF to ON
- This allows users to build Python bindings with static libOpen3D if desired
- Updated Dockerfile.wheel comment to reflect the new approach
- CI/Docker/build scripts still remove explicit BUILD_SHARED_LIBS=OFF to use the default

Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot Do not change CMakeLists.txt, i.e. allow the option of building python bindings with a static libOpen3D. Instead only change CI, build scripts and docker files to build Python wheels with a s...

Done. Changed BUILD_SHARED_LIBS default to ON instead of forcing it. This allows building Python bindings with static libOpen3D if explicitly set to OFF, while CI/Docker/build scripts use the new default (ON) for wheel builds. See commit fe53c51.

@ssheorey
Copy link
Member

@copilot Update this branch from main.

Copy link
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot Update this branch from main.

Done. Branch updated from main. Merged 8 new commits including improvements to NumPy array handling, Filament/GLFW upgrades, VoxelGrid features, and various bug fixes. See merge commit a416973.

@ssheorey ssheorey force-pushed the copilot/separate-pybind-and-libopen3d branch from d183299 to cd28a36 Compare January 22, 2026 06:05
@ssheorey ssheorey force-pushed the copilot/separate-pybind-and-libopen3d branch from cd28a36 to c6e7482 Compare January 23, 2026 21:30
@ssheorey ssheorey added this to the v0.20 milestone Mar 4, 2026
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.

2 participants