Separate pybind module from libOpen3D shared library in Python wheels#7355
Separate pybind module from libOpen3D shared library in Python wheels#7355
Conversation
|
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
- 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 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>
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. |
|
@copilot Update this branch from main. |
…/separate-pybind-and-libopen3d
…e-pybind-and-libopen3d
…l-org/Open3D into copilot/separate-pybind-and-libopen3d
…e-pybind-and-libopen3d
d183299 to
cd28a36
Compare
cd28a36 to
c6e7482
Compare
Type
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:
python util/check_style.py --applyto apply Open3D code style to my code.Description
Core build logic:
BUILD_SHARED_LIBSfromOFFtoONin CMakeLists.txt-DBUILD_SHARED_LIBS=OFFif neededCI/Docker updates:
BUILD_SHARED_LIBS=OFFfrom:docker/Dockerfile.wheelutil/ci_utils.sh(build_pip_package function).github/workflows/windows.yml(wheel build)STATIC_WINDOWS_RUNTIME=ONfrom Windows wheel build (shared libs require DLL runtime)macOS fix:
NOT BUILD_SHARED_LIBScondition from OpenMP library packaging (previously unhandled)Branch updates:
Result:
By default, wheels now contain:
Instead of:
Users can still build Python bindings with static libOpen3D by explicitly setting
BUILD_SHARED_LIBS=OFFif needed for custom builds.User code unchanged:
import open3dworks identically.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.