Skip to content

Commit

Permalink
Use scikit-build and existing CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Wittgen authored and Matthias Wittgen committed Jan 4, 2025
1 parent 8859aa5 commit 857deb3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions python/lsst/sphgeom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
find_package(pybind11 REQUIRED)

pybind11_add_module(_sphgeom
_angle.cc
_angleInterval.cc
Expand Down
21 changes: 2 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,8 @@
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=".",
)

0 comments on commit 857deb3

Please sign in to comment.