Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use system nanobind if installed #880

Merged
merged 6 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "src/third_party/quickhull"]
path = src/third_party/quickhull
url = https://github.com/akuukka/quickhull
[submodule "bindings/python/third_party/nanobind"]
path = bindings/python/third_party/nanobind
url = https://github.com/wjakob/nanobind
20 changes: 19 additions & 1 deletion bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,25 @@

project(python)

add_subdirectory(third_party)
execute_process(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for nix, there is no python nanobind package. I think we can do find_package(nanobind 1.8.0 CONFIG REQUIRED), and if nanobind_FOUND is not defined we can do the fetch content?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already trying to FetchContent:

manifold-tbb> -- nanobind not found, downloading from source
manifold-tbb> CMake Error at /nix/store/q1nssraba326p2kp6627hldd2bhg254c-cmake-3.29.2/share/cmake-3.29/Modules/ExternalProject.cmake:2945 (message):
manifold-tbb>   error: could not find git for clone of nanobind-populate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this works:

@@ -35,7 +35,7 @@
                 cmake
                 ninja
                 (python3.withPackages
-                  (ps: with ps; [ trimesh pytest ]))
+                  (ps: with ps; [ nanobind trimesh pytest ]))
                 gtest
                 pkg-config
               ]) ++ build-tools;

but build_nix_python is still broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK:

@@ -133,6 +133,7 @@
                 pkg-config
               ];
               checkInputs = [
+                nanobind
                 trimesh
                 pytest
               ];

COMMAND "${Python_EXECUTABLE}" -m nanobind --version
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_VERSION)
if(NB_VERSION VERSION_GREATER_EQUAL 1.8.0)
message("Found nanobind, version ${NB_VERSION}")
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG REQUIRED)
else()
message(STATUS "nanobind not found, downloading from source")
include(FetchContent)
FetchContent_Declare(nanobind
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
GIT_TAG 8d7f1ee0621c17fa370b704b2100ffa0243d5bf # v2.0.0
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(nanobind)
endif()
nanobind_add_module(
manifold3d
NB_STATIC STABLE_ABI LTO
Expand Down
1 change: 0 additions & 1 deletion bindings/python/third_party/nanobind
Submodule nanobind deleted from 8d7f1e
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
cmake
ninja
(python3.withPackages
(ps: with ps; [ trimesh pytest ]))
(ps: with ps; [ nanobind trimesh pytest ]))
gtest
pkg-config
]) ++ build-tools;
Expand Down Expand Up @@ -134,6 +134,7 @@
pkg-config
];
checkInputs = [
nanobind
trimesh
pytest
];
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ dependencies = [
"Bug Tracker" = "https://github.com/elalish/manifold/issues"

[build-system]
requires = ["scikit-build-core"]
requires = [
"nanobind>=1.8.0",
"scikit-build-core",
]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
Expand All @@ -40,8 +43,6 @@ sdist.exclude = [
"samples",
"test",
"oneTBB", # we may have this when we build with cibuildwheel
"bindings/python/third_party/nanobind/tests/",
"bindings/python/third_party/nanobind/docs/",
]
wheel.packages = ["manifold3d"]
cmake.args = ["-DMANIFOLD_PYBIND=ON", "-DMANIFOLD_PAR=TBB", "-DMANIFOLD_TEST=OFF", "-DBUILD_SHARED_LIBS=OFF"]
Expand Down
Loading