From 80a48ca33c5d57d9b0597aacfe72fd0f87d40be6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 13 Dec 2023 15:57:30 -0800 Subject: [PATCH] Switch to scikit-build-core (#2051) Contributes to rapidsai/build-planning#2 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Corey J. Nolet (https://github.com/cjnolet) URL: https://github.com/rapidsai/raft/pull/2051 --- build.sh | 8 ++-- ci/build_wheel_pylibraft.sh | 2 +- ci/build_wheel_raft_dask.sh | 2 +- .../all_cuda-118_arch-aarch64.yaml | 2 +- .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-120_arch-aarch64.yaml | 2 +- .../all_cuda-120_arch-x86_64.yaml | 2 +- .../bench_ann_cuda-118_arch-aarch64.yaml | 2 +- .../bench_ann_cuda-118_arch-x86_64.yaml | 2 +- .../bench_ann_cuda-120_arch-aarch64.yaml | 2 +- .../bench_ann_cuda-120_arch-x86_64.yaml | 2 +- conda/recipes/pylibraft/meta.yaml | 2 +- conda/recipes/raft-dask/meta.yaml | 2 +- dependencies.yaml | 7 ++-- python/pylibraft/CMakeLists.txt | 8 +--- python/pylibraft/README.md | 1 + python/pylibraft/pyproject.toml | 25 ++++++++----- python/pylibraft/setup.py | 37 ------------------- python/raft-dask/CMakeLists.txt | 8 +--- python/raft-dask/README.md | 1 + python/raft-dask/pyproject.toml | 24 +++++++----- python/raft-dask/setup.py | 36 ------------------ 22 files changed, 56 insertions(+), 123 deletions(-) create mode 120000 python/pylibraft/README.md delete mode 100644 python/pylibraft/setup.py create mode 120000 python/raft-dask/README.md delete mode 100644 python/raft-dask/setup.py diff --git a/build.sh b/build.sh index 200d6710e0..e5df0af826 100755 --- a/build.sh +++ b/build.sh @@ -386,6 +386,8 @@ SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RAFT_CPP"* ]]; then SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_RAFT_CPP=ON" fi +# Replace spaces with semicolons in SKBUILD_EXTRA_CMAKE_ARGS +SKBUILD_EXTRA_CMAKE_ARGS=$(echo ${SKBUILD_EXTRA_CMAKE_ARGS} | sed 's/ /;/g') # If clean given, run it prior to any other steps if (( ${CLEAN} == 1 )); then @@ -493,15 +495,13 @@ fi # Build and (optionally) install the pylibraft Python package if (( ${NUMARGS} == 0 )) || hasArg pylibraft; then - SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS}" \ - SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL}" \ + SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \ python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/pylibraft fi # Build and (optionally) install the raft-dask Python package if (( ${NUMARGS} == 0 )) || hasArg raft-dask; then - SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS}" \ - SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL}" \ + SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \ python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/raft-dask fi diff --git a/ci/build_wheel_pylibraft.sh b/ci/build_wheel_pylibraft.sh index 48e20f597e..ec30a28b92 100755 --- a/ci/build_wheel_pylibraft.sh +++ b/ci/build_wheel_pylibraft.sh @@ -4,6 +4,6 @@ set -euo pipefail # Set up skbuild options. Enable sccache in skbuild config options -export SKBUILD_CONFIGURE_OPTIONS="-DDETECT_CONDA_ENV=OFF -DFIND_RAFT_CPP=OFF" +export SKBUILD_CMAKE_ARGS="-DDETECT_CONDA_ENV=OFF;-DFIND_RAFT_CPP=OFF" ci/build_wheel.sh pylibraft python/pylibraft diff --git a/ci/build_wheel_raft_dask.sh b/ci/build_wheel_raft_dask.sh index cad09602dc..5ae12303d0 100755 --- a/ci/build_wheel_raft_dask.sh +++ b/ci/build_wheel_raft_dask.sh @@ -4,6 +4,6 @@ set -euo pipefail # Set up skbuild options. Enable sccache in skbuild config options -export SKBUILD_CONFIGURE_OPTIONS="-DDETECT_CONDA_ENV=OFF -DFIND_RAFT_CPP=OFF" +export SKBUILD_CMAKE_ARGS="-DDETECT_CONDA_ENV=OFF;-DFIND_RAFT_CPP=OFF" ci/build_wheel.sh raft-dask python/raft-dask diff --git a/conda/environments/all_cuda-118_arch-aarch64.yaml b/conda/environments/all_cuda-118_arch-aarch64.yaml index ce1fed94f7..ac076f5505 100644 --- a/conda/environments/all_cuda-118_arch-aarch64.yaml +++ b/conda/environments/all_cuda-118_arch-aarch64.yaml @@ -49,7 +49,7 @@ dependencies: - rapids-dask-dependency==24.2.* - recommonmark - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - scikit-learn - scipy - sphinx-copybutton diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 16504fb4ca..b3ded51bb5 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -49,7 +49,7 @@ dependencies: - rapids-dask-dependency==24.2.* - recommonmark - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - scikit-learn - scipy - sphinx-copybutton diff --git a/conda/environments/all_cuda-120_arch-aarch64.yaml b/conda/environments/all_cuda-120_arch-aarch64.yaml index b2d4a50df8..c0eede1389 100644 --- a/conda/environments/all_cuda-120_arch-aarch64.yaml +++ b/conda/environments/all_cuda-120_arch-aarch64.yaml @@ -45,7 +45,7 @@ dependencies: - rapids-dask-dependency==24.2.* - recommonmark - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - scikit-learn - scipy - sphinx-copybutton diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index adb1fd74b7..cebaf96493 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -45,7 +45,7 @@ dependencies: - rapids-dask-dependency==24.2.* - recommonmark - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - scikit-learn - scipy - sphinx-copybutton diff --git a/conda/environments/bench_ann_cuda-118_arch-aarch64.yaml b/conda/environments/bench_ann_cuda-118_arch-aarch64.yaml index 39c6d24889..87e3942e6a 100644 --- a/conda/environments/bench_ann_cuda-118_arch-aarch64.yaml +++ b/conda/environments/bench_ann_cuda-118_arch-aarch64.yaml @@ -39,6 +39,6 @@ dependencies: - pandas - pyyaml - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - sysroot_linux-aarch64==2.17 name: bench_ann_cuda-118_arch-aarch64 diff --git a/conda/environments/bench_ann_cuda-118_arch-x86_64.yaml b/conda/environments/bench_ann_cuda-118_arch-x86_64.yaml index e0f46085d3..a4ac253a85 100644 --- a/conda/environments/bench_ann_cuda-118_arch-x86_64.yaml +++ b/conda/environments/bench_ann_cuda-118_arch-x86_64.yaml @@ -39,6 +39,6 @@ dependencies: - pandas - pyyaml - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - sysroot_linux-64==2.17 name: bench_ann_cuda-118_arch-x86_64 diff --git a/conda/environments/bench_ann_cuda-120_arch-aarch64.yaml b/conda/environments/bench_ann_cuda-120_arch-aarch64.yaml index 2c69bc5325..9ef9799363 100644 --- a/conda/environments/bench_ann_cuda-120_arch-aarch64.yaml +++ b/conda/environments/bench_ann_cuda-120_arch-aarch64.yaml @@ -35,6 +35,6 @@ dependencies: - pandas - pyyaml - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - sysroot_linux-aarch64==2.17 name: bench_ann_cuda-120_arch-aarch64 diff --git a/conda/environments/bench_ann_cuda-120_arch-x86_64.yaml b/conda/environments/bench_ann_cuda-120_arch-x86_64.yaml index 4f4b0d5019..5fa09096ba 100644 --- a/conda/environments/bench_ann_cuda-120_arch-x86_64.yaml +++ b/conda/environments/bench_ann_cuda-120_arch-x86_64.yaml @@ -35,6 +35,6 @@ dependencies: - pandas - pyyaml - rmm==24.2.* -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - sysroot_linux-64==2.17 name: bench_ann_cuda-120_arch-x86_64 diff --git a/conda/recipes/pylibraft/meta.yaml b/conda/recipes/pylibraft/meta.yaml index b8a088d0f3..c736ffb877 100644 --- a/conda/recipes/pylibraft/meta.yaml +++ b/conda/recipes/pylibraft/meta.yaml @@ -50,7 +50,7 @@ requirements: - libraft-headers {{ version }} - python x.x - rmm ={{ minor_version }} - - scikit-build >=0.13.1 + - scikit-build-core >=0.7.0 - setuptools run: - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} diff --git a/conda/recipes/raft-dask/meta.yaml b/conda/recipes/raft-dask/meta.yaml index eae5a6affe..944b500428 100644 --- a/conda/recipes/raft-dask/meta.yaml +++ b/conda/recipes/raft-dask/meta.yaml @@ -50,7 +50,7 @@ requirements: - pylibraft {{ version }} - python x.x - rmm ={{ minor_version }} - - scikit-build >=0.13.1 + - scikit-build-core >=0.7.0 - setuptools - ucx {{ ucx_version }} - ucx-proc=*=gpu diff --git a/dependencies.yaml b/dependencies.yaml index 64ff648c48..f049c75511 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -64,7 +64,6 @@ files: includes: - build - build_pylibraft - - build_wheels py_run_pylibraft: output: pyproject pyproject_dir: python/pylibraft @@ -89,7 +88,6 @@ files: table: build-system includes: - build - - build_wheels py_run_raft_dask: output: pyproject pyproject_dir: python/raft-dask @@ -133,12 +131,15 @@ dependencies: - &cmake_ver cmake>=3.26.4 - cython>=3.0.0 - ninja - - scikit-build>=0.13.1 - output_types: [conda] packages: - c-compiler - cxx-compiler - nccl>=2.9.9 + - scikit-build-core>=0.7.0 + - output_types: [requirements, pyproject] + packages: + - scikit-build-core[pyproject]>=0.7.0 specific: - output_types: conda matrices: diff --git a/python/pylibraft/CMakeLists.txt b/python/pylibraft/CMakeLists.txt index 3b0417b850..f7e114ae66 100644 --- a/python/pylibraft/CMakeLists.txt +++ b/python/pylibraft/CMakeLists.txt @@ -26,11 +26,7 @@ rapids_cuda_init_architectures(pylibraft) project( pylibraft VERSION ${pylibraft_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_RAFT_CPP "Search for existing RAFT C++ installations before defaulting to local files" @@ -51,7 +47,7 @@ else() set(raft_FOUND OFF) endif() -include(rapids-cython) +include(rapids-cython-core) if(NOT raft_FOUND) set(BUILD_TESTS OFF) diff --git a/python/pylibraft/README.md b/python/pylibraft/README.md new file mode 120000 index 0000000000..fe84005413 --- /dev/null +++ b/python/pylibraft/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/pylibraft/pyproject.toml b/python/pylibraft/pyproject.toml index f811afa55f..5070d6cf6f 100644 --- a/python/pylibraft/pyproject.toml +++ b/python/pylibraft/pyproject.toml @@ -20,11 +20,9 @@ requires = [ "cython>=3.0.0", "ninja", "rmm==24.2.*", - "scikit-build>=0.13.1", - "setuptools", - "wheel", + "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. -build-backend = "setuptools.build_meta" +build-backend = "scikit_build_core.build" [project] name = "pylibraft" @@ -61,12 +59,6 @@ test = [ Homepage = "https://github.com/rapidsai/raft" Documentation = "https://docs.rapids.ai/api/raft/stable/" -[tool.setuptools] -license-files = ["LICENSE"] - -[tool.setuptools.dynamic] -version = {file = "pylibraft/VERSION"} - [tool.isort] line_length = 79 multi_line_output = 3 @@ -109,3 +101,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 = ["pylibraft"] + +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "pylibraft/VERSION" +regex = "(?P.*)" diff --git a/python/pylibraft/setup.py b/python/pylibraft/setup.py deleted file mode 100644 index 738bc2cf5b..0000000000 --- a/python/pylibraft/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2022-2023, NVIDIA CORPORATION. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from setuptools import find_packages -from skbuild import setup - - -def exclude_libcxx_symlink(cmake_manifest): - return list( - filter( - lambda name: not ("include/rapids/libcxx/include" in name), - cmake_manifest, - ) - ) - - -packages = find_packages(include=["pylibraft*"]) -setup( - # Don't want libcxx getting pulled into wheel builds. - cmake_process_manifest_hook=exclude_libcxx_symlink, - packages=packages, - package_data={key: ["VERSION", "*.pxd"] for key in packages}, - zip_safe=False, -) diff --git a/python/raft-dask/CMakeLists.txt b/python/raft-dask/CMakeLists.txt index 0deed549a7..1d27e49583 100644 --- a/python/raft-dask/CMakeLists.txt +++ b/python/raft-dask/CMakeLists.txt @@ -23,11 +23,7 @@ rapids_cuda_init_architectures(raft-dask-python) project( raft-dask-python VERSION ${raft_dask_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_RAFT_CPP "Search for existing RAFT C++ installations before defaulting to local files" @@ -59,7 +55,7 @@ if(NOT raft_FOUND) find_package(NCCL REQUIRED) endif() -include(rapids-cython) +include(rapids-cython-core) rapids_cython_init() add_subdirectory(raft_dask/common) diff --git a/python/raft-dask/README.md b/python/raft-dask/README.md new file mode 120000 index 0000000000..fe84005413 --- /dev/null +++ b/python/raft-dask/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/raft-dask/pyproject.toml b/python/raft-dask/pyproject.toml index 807c413160..37d94be7f9 100644 --- a/python/raft-dask/pyproject.toml +++ b/python/raft-dask/pyproject.toml @@ -14,13 +14,12 @@ [build-system] +build-backend = "scikit_build_core.build" requires = [ "cmake>=3.26.4", "cython>=3.0.0", "ninja", - "scikit-build>=0.13.1", - "setuptools", - "wheel", + "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project] @@ -59,12 +58,6 @@ test = [ Homepage = "https://github.com/rapidsai/raft" Documentation = "https://docs.rapids.ai/api/raft/stable/" -[tool.setuptools] -license-files = ["LICENSE"] - -[tool.setuptools.dynamic] -version = {file = "raft_dask/VERSION"} - [tool.isort] line_length = 79 multi_line_output = 3 @@ -108,3 +101,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 = ["raft_dask"] + +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "raft_dask/VERSION" +regex = "(?P.*)" diff --git a/python/raft-dask/setup.py b/python/raft-dask/setup.py deleted file mode 100644 index dda58c3341..0000000000 --- a/python/raft-dask/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (c) 2020-2023, NVIDIA CORPORATION. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from setuptools import find_packages -from skbuild import setup - - -def exclude_libcxx_symlink(cmake_manifest): - return list( - filter( - lambda name: not ("include/rapids/libcxx/include" in name), - cmake_manifest, - ) - ) - - -packages = find_packages(include=["raft_dask*"]) -setup( - cmake_process_manifest_hook=exclude_libcxx_symlink, - packages=packages, - package_data={key: ["VERSION", "*.pxd"] for key in packages}, - zip_safe=False, -)