diff --git a/features/src/rapids-build-utils/devcontainer-feature.json b/features/src/rapids-build-utils/devcontainer-feature.json index 8680eeca..715a510c 100644 --- a/features/src/rapids-build-utils/devcontainer-feature.json +++ b/features/src/rapids-build-utils/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "NVIDIA RAPIDS devcontainer build utilities", "id": "rapids-build-utils", - "version": "24.6.3", + "version": "24.6.4", "description": "A feature to install the RAPIDS devcontainer build utilities", "containerEnv": { "BASH_ENV": "/etc/bash.bash_env" diff --git a/features/src/rapids-build-utils/install.sh b/features/src/rapids-build-utils/install.sh index 3c10a919..20c5cb80 100644 --- a/features/src/rapids-build-utils/install.sh +++ b/features/src/rapids-build-utils/install.sh @@ -59,6 +59,7 @@ declare -a commands=( python-conda-pkg-names python-pkg-names python-pkg-roots + python-uses-scikit-build python-uses-scikit-build-core query-manifest select-cmake-args diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-cmake-build-dir.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-cmake-build-dir.sh index 06d3f054..cd664749 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-cmake-build-dir.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-cmake-build-dir.sh @@ -36,38 +36,42 @@ get_cmake_build_dir() { # shellcheck disable=SC1091 . devcontainer-utils-debug-output 'rapids_build_utils_debug' 'get-cmake-build-dir'; - if test "${REST[0]:-}" == --; then REST=("${REST[@]:1}"); fi; + if test "${REST[0]:-}" == --; then REST=("${REST[@]:1}"); fi - local bin="build"; local src="${REST[0]:-}"; - local -r type="$(rapids-select-cmake-build-type "${OPTS[@]}" "${REST[@]:1}" | tr '[:upper:]' '[:lower:]')"; - local -r cuda="$(grep -o '^[0-9]*.[0-9]*' <<< "${CUDA_VERSION:-${CUDA_VERSION_MAJOR:-12}.${CUDA_VERSION_MINOR:-0}}")"; - bin+="${PYTHON_PACKAGE_MANAGER:+/${PYTHON_PACKAGE_MANAGER}}${cuda:+/cuda-${cuda}}"; + if test -n "${src}" && rapids-python-uses-scikit-build "${src}"; then + echo "${src:+${src}/}$(python -c 'from skbuild import constants; print(constants.CMAKE_BUILD_DIR())')"; + else + local -r type="$(rapids-select-cmake-build-type "${OPTS[@]}" "${REST[@]:1}" | tr '[:upper:]' '[:lower:]')"; + local -r cuda="$(grep -o '^[0-9]*.[0-9]*' <<< "${CUDA_VERSION:-${CUDA_VERSION_MAJOR:-12}.${CUDA_VERSION_MINOR:-0}}")"; + local bin="build"; + bin+="${PYTHON_PACKAGE_MANAGER:+/${PYTHON_PACKAGE_MANAGER}}${cuda:+/cuda-${cuda}}"; - if test -n "${src:-}" && test -d "${src:-}"; then - mkdir -p "${src}/${bin}"; - if test -z "${skip_links-}"; then - if test -z "${skip_build_type-}" || ! test -L "${src}/${bin}/latest"; then - mkdir -p "${src}/${bin}/${type}"; - cd "${src}/${bin}/" || exit 1; - ln -sfn "${type}" latest; - fi - cd "${src}/build" || exit 1; - local component; - for component in "${PYTHON_PACKAGE_MANAGER:-}" "${cuda:+cuda-${cuda}}"; do - if test -n "${component:-}"; then - ln -sfn "${component}/latest" latest; - cd "${component}" || exit 1; + if test -n "${src:-}" && test -d "${src:-}"; then + mkdir -p "${src}/${bin}"; + if test -z "${skip_links-}"; then + if test -z "${skip_build_type-}" || ! test -L "${src}/${bin}/latest"; then + mkdir -p "${src}/${bin}/${type}"; + cd "${src}/${bin}/" || exit 1; + ln -sfn "${type}" latest; fi - done + cd "${src}/build" || exit 1; + local component; + for component in "${PYTHON_PACKAGE_MANAGER:-}" "${cuda:+cuda-${cuda}}"; do + if test -n "${component:-}"; then + ln -sfn "${component}/latest" latest; + cd "${component}" || exit 1; + fi + done + fi fi - fi - if test -n "${skip_build_type-}"; then - echo "${src:+${src}/}${bin}/latest"; - else - echo "${src:+${src}/}${bin}/${type}"; + if test -n "${skip_build_type-}"; then + echo "${src:+${src}/}${bin}/latest"; + else + echo "${src:+${src}/}${bin}/${type}"; + fi fi } diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/maybe-clean-build-dir.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/maybe-clean-build-dir.sh index 1cf6a39d..75552a02 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/maybe-clean-build-dir.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/maybe-clean-build-dir.sh @@ -27,12 +27,15 @@ maybe_clean_build_dir() { local -r bin_dir="$(rapids-get-cmake-build-dir "${OPTS[@]}" "${REST[@]}")"; - case "${G:-Ninja}" in - "Unix Makefiles") - test -f "${bin_dir}/Makefile" || rm -rf "${bin_dir}";; - "Ninja") - test -f "${bin_dir}/build.ninja" || rm -rf "${bin_dir}";; - esac + if test -n "${bin_dir-}" && test -d "${bin_dir}"; then + case "${G:-Ninja}" in + "Unix Makefiles") + test -f "${bin_dir}/Makefile" || rm -rf "${bin_dir}";; + "Ninja") + test -f "${bin_dir}/build.ninja" || rm -rf "${bin_dir}";; + esac + fi + echo "${bin_dir}"; } diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/merge-compile-commands-json.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/merge-compile-commands-json.sh index 7314ce5c..9ea04efc 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/merge-compile-commands-json.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/merge-compile-commands-json.sh @@ -33,7 +33,8 @@ _list_repo_paths() { for ((j=0; j < ${!py_length:-0}; j+=1)); do local py_sub_dir="${repo}_python_${j}_sub_dir"; local py_path=~/"${!repo_path:-}${!py_sub_dir:+/${!py_sub_dir}}"; - if rapids-python-uses-scikit-build-core "${py_path}"; then + if rapids-python-uses-scikit-build "${py_path}" \ + || rapids-python-uses-scikit-build-core "${py_path}"; then echo "${py_path}"; fi done diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build-core.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build-core.sh index 1d74057f..ea699b0f 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build-core.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build-core.sh @@ -3,4 +3,4 @@ set -e; test -f "${1}/pyproject.toml"; -test "scikit_build_core.build" = "$(python -c "import toml; print(toml.load('${1}/pyproject.toml')['build-system']['build-backend'])" 2>/dev/null)"; +test "scikit_build_core.build" = "$(/usr/local/python/current/bin/python -c "import toml; print(toml.load('${1}/pyproject.toml')['build-system']['build-backend'])" 2>/dev/null)"; diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build.sh new file mode 100755 index 00000000..28caf80d --- /dev/null +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/python-uses-scikit-build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e; + +test -f "${1}/pyproject.toml"; +test "True" = "$(/usr/local/python/current/bin/python -c "import toml; print(any('scikit-build-core' not in x and 'scikit-build' in x for x in toml.load('${1}/pyproject.toml')['build-system']['requires']))" 2>/dev/null)"; diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.build.wheel.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.build.wheel.tmpl.sh index 03f28c8c..3d03fc28 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.build.wheel.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.build.wheel.tmpl.sh @@ -68,7 +68,12 @@ build_${PY_LIB}_python_wheel() { $(rapids-select-pip-wheel-args "$@") )"; - if rapids-python-uses-scikit-build-core "${PY_SRC}"; then + if rapids-python-uses-scikit-build "${PY_SRC}"; then + # Clean the `_skbuild/.../cmake-build` dir if configuration failed before + if ! test -d "$(rapids-maybe-clean-build-dir "${cmake_args[@]}" -- "${PY_SRC}")"; then + rm -rf "${PY_SRC}/_skbuild"; + fi + elif rapids-python-uses-scikit-build-core "${PY_SRC}"; then pip_args+=(-C "build-dir=$(rapids-maybe-clean-build-dir "${cmake_args[@]}" -- "${PY_SRC}")"); fi diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.install.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.install.tmpl.sh index 6fef662c..f18f15fd 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.install.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python.install.tmpl.sh @@ -66,10 +66,16 @@ install_${PY_LIB}_python() { $(rapids-select-pip-install-args "$@") )"; - if rapids-python-uses-scikit-build-core "${PY_SRC}"; then + if rapids-python-uses-scikit-build "${PY_SRC}"; then + # Clean the `_skbuild/.../cmake-build` dir if configuration failed before + if ! test -d "$(rapids-maybe-clean-build-dir "${cmake_args[@]}" -- "${PY_SRC}")"; then + rm -rf "${PY_SRC}/_skbuild"; + fi + if test ${#editable[@]} -gt 0; then + export SETUPTOOLS_ENABLE_FEATURES=legacy-editable; + fi + elif rapids-python-uses-scikit-build-core "${PY_SRC}"; then pip_args+=(-C "build-dir=$(rapids-maybe-clean-build-dir "${cmake_args[@]}" -- "${PY_SRC}")"); - elif test ${#editable[@]} -gt 0; then - export SETUPTOOLS_ENABLE_FEATURES=legacy-editable; fi # Put --editable at the end of pip_args