Skip to content

Commit

Permalink
Switch to scikit-build-core (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr authored Dec 13, 2023
1 parent cdccd49 commit 60de429
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 109 deletions.
6 changes: 2 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,14 @@ fi
if (( ${NUMARGS} == 0 )) || hasArg cuspatial; then

cd ${REPODIR}/python/cuspatial
SKBUILD_CONFIGURE_OPTIONS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUSPATIAL_BUILD_DIR} ${EXTRA_CMAKE_ARGS}" \
SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL:-1}" \
SKBUILD_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX};-DCMAKE_LIBRARY_PATH=${LIBCUSPATIAL_BUILD_DIR};${EXTRA_CMAKE_ARGS}" \
python -m pip install --no-build-isolation --no-deps .
fi

# Build and install the cuproj Python package
if (( ${NUMARGS} == 0 )) || hasArg cuproj; then

cd ${REPODIR}/python/cuproj
SKBUILD_CONFIGURE_OPTIONS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUPROJ_BUILD_DIR} ${EXTRA_CMAKE_ARGS}" \
SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL:-1}" \
SKBUILD_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX};-DCMAKE_LIBRARY_PATH=${LIBCUPROJ_BUILD_DIR};${EXTRA_CMAKE_ARGS}" \
python -m pip install --no-build-isolation --no-deps .
fi
2 changes: 0 additions & 2 deletions ci/build_wheel_cuproj.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

set -euo pipefail

export SKBUILD_CONFIGURE_OPTIONS="-DCUPROJ_BUILD_WHEELS=ON"

ci/build_wheel.sh cuproj python/cuproj
3 changes: 1 addition & 2 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ dependencies:
- pytest-xdist
- python>=3.9,<3.11
- rmm==24.2.*
- scikit-build>=0.13.1
- scikit-build-core>=0.7.0
- scikit-image
- setuptools
- shapely
- sphinx<6
- sqlite
Expand Down
3 changes: 1 addition & 2 deletions conda/environments/all_cuda-120_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ dependencies:
- pytest-xdist
- python>=3.9,<3.11
- rmm==24.2.*
- scikit-build>=0.13.1
- scikit-build-core>=0.7.0
- scikit-image
- setuptools
- shapely
- sphinx<6
- sqlite
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/cuproj/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ requirements:
- cython >=3.0.0
- python
- rmm ={{ minor_version }}
- scikit-build >=0.13.1
- scikit-build-core >=0.7.0
- setuptools
- proj
- sqlite
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/cuspatial/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ requirements:
- libcuspatial ={{ version }}
- python
- rmm ={{ minor_version }}
- scikit-build >=0.13.1
- scikit-build-core >=0.7.0
- setuptools
run:
{% if cuda_major == "11" %}
Expand Down
26 changes: 5 additions & 21 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ files:
includes:
- depends_on_rmm
- build_cpp_cuproj
- build_python_cuproj
- build_python
- build_wheels
py_run_cuproj:
output: [pyproject]
Expand Down Expand Up @@ -207,28 +207,12 @@ dependencies:
- output_types: [conda, requirements, pyproject]
packages:
- cython>=3.0.0
- scikit-build>=0.13.1
- setuptools
specific:
- output_types: conda
matrices:
- matrix:
arch: x86_64
packages:
- *gcc_amd64
- *sysroot_amd64
- matrix:
arch: aarch64
packages:
- *gcc_aarch64
- *sysroot_aarch64
build_python_cuproj:
common:
- output_types: [conda, requirements, pyproject]
packages:
- cython>=3.0.0
- scikit-build>=0.13.1
- setuptools
- scikit-build-core>=0.7.0
- output_types: [requirements, pyproject]
packages:
- scikit-build-core[pyproject]>=0.7.0
specific:
- output_types: conda
matrices:
Expand Down
33 changes: 5 additions & 28 deletions python/cuproj/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ rapids_cuda_init_architectures(cuproj-python)
project(
cuproj-python
VERSION ${cuproj_version}
LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C
# language to be enabled here. The test project that is built in scikit-build to verify
# various linking options for the python library is hardcoded to build with C, so until
# that is fixed we need to keep C.
C CXX CUDA)
LANGUAGES CXX CUDA)

option(FIND_CUPROJ_CPP "Search for existing cuproj C++ installations before defaulting to local files"
OFF)

option(CUPROJ_BUILD_WHEELS "Whether this build is generating a Python wheel." OFF)

# If the user requested it we attempt to find cuproj.
if(FIND_CUPROJ_CPP)
find_package(cuproj ${cuproj_version})
Expand All @@ -44,37 +38,20 @@ endif()
if(NOT cuproj_FOUND)
set(BUILD_TESTS OFF)
set(BUILD_BENCHMARKS OFF)
set(_exclude_from_all "")
if(CUPROJ_BUILD_WHEELS)

# Statically link cudart if building wheels
set(CUDA_STATIC_RUNTIME ON)

# Need to set this so all the cuproj targets are global, not only cuproj::cuproj
# https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.html#variable:CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON)

# Don't install the cuProj C++ targets into wheels
set(_exclude_from_all EXCLUDE_FROM_ALL)
endif()
set(CUDA_STATIC_RUNTIME ON)

add_subdirectory(../../cpp/cuproj cuproj-cpp ${_exclude_from_all})

set(cython_lib_dir cuproj)

if(CUPROJ_BUILD_WHEELS)
include(../cuspatial/cmake/Modules/WheelHelpers.cmake)
endif()
add_subdirectory(../../cpp/cuproj cuproj-cpp EXCLUDE_FROM_ALL)

# Since there are multiple subpackages of cuproj._lib that require access to libcuspatial, we place the
# library in the cuproj directory as a single source of truth and modify the other rpaths
# appropriately.
set(cython_lib_dir cuproj)
install(TARGETS cuproj DESTINATION ${cython_lib_dir})
endif()

add_subdirectory(cuproj/cuprojshim)

include(rapids-cython)
include(rapids-cython-core)
rapids_cython_init()

add_subdirectory(cuproj/_lib)
Expand Down
24 changes: 16 additions & 8 deletions python/cuproj/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.

[build-system]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"
requires = [
"cmake>=3.26.4",
"cython>=3.0.0",
"ninja",
"rmm==24.2.*",
"scikit-build>=0.13.1",
"scikit-build-core[pyproject]>=0.7.0",
"setuptools",
"wheel",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
Expand Down Expand Up @@ -60,12 +60,6 @@ test = [
Homepage = "https://github.com/rapidsai/cuspatial/python/cuproj"
Documentation = "https://docs.rapids.ai/api/cuproj/stable/"

[tool.setuptools]
license-files = ["LICENSE"]

[tool.setuptools.dynamic]
version = {file = "cuproj/VERSION"}

[tool.isort]
line_length = 79
multi_line_output = 3
Expand Down Expand Up @@ -100,3 +94,17 @@ skip = [
"dist",
"__init__.py",
]

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.build-type = "Release"
cmake.minimum-version = "3.26.4"
ninja.make-fallback = true
sdist.reproducible = true
wheel.exclude = ["*.clang-format"]
wheel.packages = ["cuproj"]

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "cuproj/VERSION"
regex = "(?P<value>.*)"
13 changes: 0 additions & 13 deletions python/cuproj/setup.py

This file was deleted.

8 changes: 2 additions & 6 deletions python/cuspatial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ rapids_cuda_init_architectures(cuspatial-python)
project(
cuspatial-python
VERSION ${cuspatial_version}
LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C
# language to be enabled here. The test project that is built in scikit-build to verify
# various linking options for the python library is hardcoded to build with C, so until
# that is fixed we need to keep C.
C CXX CUDA)
LANGUAGES CXX CUDA)

option(FIND_CUSPATIAL_CPP "Search for existing cuspatial C++ installations before defaulting to local files"
OFF)
Expand Down Expand Up @@ -60,7 +56,7 @@ if(NOT cuspatial_FOUND)
)
endif()

include(rapids-cython)
include(rapids-cython-core)
rapids_cython_init()

add_subdirectory(cuspatial/_lib)
Expand Down
23 changes: 15 additions & 8 deletions python/cuspatial/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.

[build-system]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"
requires = [
"cmake>=3.26.4",
"cudf==24.2.*",
"cython>=3.0.0",
"ninja",
"rmm==24.2.*",
"scikit-build>=0.13.1",
"scikit-build-core[pyproject]>=0.7.0",
"setuptools",
"wheel",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
Expand Down Expand Up @@ -61,12 +61,6 @@ test = [
Homepage = "https://github.com/rapidsai/cuspatial"
Documentation = "https://docs.rapids.ai/api/cuspatial/stable/"

[tool.setuptools]
license-files = ["LICENSE"]

[tool.setuptools.dynamic]
version = {file = "cuspatial/VERSION"}

[tool.isort]
line_length = 79
multi_line_output = 3
Expand Down Expand Up @@ -110,3 +104,16 @@ skip = [
"dist",
"__init__.py",
]

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.build-type = "Release"
cmake.minimum-version = "3.26.4"
ninja.make-fallback = true
sdist.reproducible = true
wheel.packages = ["cuspatial"]

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "cuspatial/VERSION"
regex = "(?P<value>.*)"
13 changes: 0 additions & 13 deletions python/cuspatial/setup.py

This file was deleted.

0 comments on commit 60de429

Please sign in to comment.