Skip to content

Commit e237437

Browse files
committed
use nanobind as pip package instead of submodule
1 parent c9c3461 commit e237437

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "ext/nanobind"]
2-
path = ext/nanobind
3-
url = https://github.com/wjakob/nanobind

CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.19...3.25)
2-
project(s2fft LANGUAGES CXX)
2+
project(s2fft LANGUAGES CXX CUDA)
33

44
message(STATUS "Using CMake version: ${CMAKE_VERSION}")
55

@@ -13,15 +13,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1313
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
1414
endif()
1515

16-
# Include directories
17-
include_directories(${CMAKE_CURRENT_LIST_DIR}/lib)
18-
1916
# Check for CUDA
2017
include(CheckLanguage)
2118
check_language(CUDA)
2219

2320
if(CMAKE_CUDA_COMPILER)
2421
enable_language(CUDA)
22+
find_package(CUDAToolkit REQUIRED)
2523
message(STATUS "CUDA compiler found: ${CMAKE_CUDA_COMPILER}")
2624

2725
if(NOT SKBUILD)
@@ -47,9 +45,15 @@ if(CMAKE_CUDA_COMPILER)
4745
set_target_properties(_s2fftExe PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
4846

4947
else()
48+
find_package(CUDAToolkit REQUIRED)
49+
5050
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
5151

52-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/nanobind)
52+
# Detect the installed nanobind package and import it into CMake
53+
execute_process(
54+
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
55+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
56+
find_package(nanobind CONFIG REQUIRED)
5357

5458
nanobind_add_module(_s2fft STABLE_ABI
5559
${CMAKE_CURRENT_LIST_DIR}/lib/src/extensions.cc
@@ -77,7 +81,10 @@ else()
7781

7882
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
7983

80-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/nanobind)
84+
execute_process(
85+
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
86+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
87+
find_package(nanobind CONFIG REQUIRED)
8188

8289
nanobind_add_module(_s2fft STABLE_ABI
8390
${CMAKE_CURRENT_LIST_DIR}/lib/src/extensions.cc
@@ -94,3 +101,4 @@ else()
94101
endif()
95102
endif()
96103

104+

ext/nanobind

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements/requirements-core.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ torch # Remove when subpackage functionality is fixed.
88
pyssht
99
healpy
1010
ducc0
11+
nanobind >=2.0.0

0 commit comments

Comments
 (0)