diff --git a/CMakeLists.txt b/CMakeLists.txt index c250195..89fcee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,16 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.17..3.30) project(sphgeom) +# Find Python interpreter and libraries + +find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter Development) +execute_process( + COMMAND "${Python3_EXECUTABLE}" -m pybind11 --cmakedir + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pybind11_ROOT + ERROR_VARIABLE error_output +) +find_package(pybind11 CONFIG REQUIRED PATHS ${pybind11_ROOT}) + enable_testing() add_subdirectory(python/lsst/sphgeom) diff --git a/pyproject.toml b/pyproject.toml index 9cbeb6b..acd3ee5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,11 @@ requires = [ "setuptools", "lsst-versions >= 1.3.0", + "scikit-build", "wheel", "pybind11 >= 2.5.0", + "cmake", + "ninja", "numpy >= 1.18", ] build-backend = "setuptools.build_meta" diff --git a/python/lsst/sphgeom/CMakeLists.txt b/python/lsst/sphgeom/CMakeLists.txt index c11dcab..1dd3b88 100644 --- a/python/lsst/sphgeom/CMakeLists.txt +++ b/python/lsst/sphgeom/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(pybind11 REQUIRED) - pybind11_add_module(_sphgeom _angle.cc _angleInterval.cc diff --git a/setup.py b/setup.py index fa4edf7..d0572b1 100644 --- a/setup.py +++ b/setup.py @@ -9,25 +9,9 @@ interface. """ -import glob - -from pybind11.setup_helpers import ParallelCompile, Pybind11Extension, build_ext -from setuptools import setup - -# Optional multithreaded build. -ParallelCompile("NPY_NUM_BUILD_JOBS").install() - -# Find the source code -- we can combine it into a single module -pybind_src = sorted(glob.glob("python/lsst/sphgeom/*.cc")) -cpp_src = sorted(glob.glob("src/*.cc")) - -# Very inefficient approach since this compiles the maing sphgeom -# library code for every extension rather than building everything once -ext_modules = [ - Pybind11Extension("lsst.sphgeom._sphgeom", sorted(cpp_src + pybind_src), include_dirs=["include"]) -] +from skbuild import setup setup( - ext_modules=ext_modules, - cmdclass={"build_ext": build_ext}, + cmake_source_dir=".", + cmake_install_dir=".", )