diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index cb070fc8..38a69516 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -49,7 +49,9 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/unified,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/unified,target=/home/coder/.conda/envs,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda11.8-conda/features/utils/opt/devcontainer/bin,target=/opt/devcontainer/bin,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda11.8-conda/features/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index aa8b5639..a42b1fd0 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -48,7 +48,9 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/unified,target=/home/coder/.local,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/unified,target=/home/coder/.local,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda11.8-pip/features/utils/opt/devcontainer/bin,target=/opt/devcontainer/bin,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda11.8-pip/features/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.0-conda/devcontainer.json index 55e65e31..52c894ea 100644 --- a/.devcontainer/cuda12.0-conda/devcontainer.json +++ b/.devcontainer/cuda12.0-conda/devcontainer.json @@ -49,7 +49,9 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/unified,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/unified,target=/home/coder/.conda/envs,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda12.0-conda/features/utils/opt/devcontainer/bin,target=/opt/devcontainer/bin,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda12.0-conda/features/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.0-pip/devcontainer.json index 3c85a2ba..add4c93b 100644 --- a/.devcontainer/cuda12.0-pip/devcontainer.json +++ b/.devcontainer/cuda12.0-pip/devcontainer.json @@ -48,7 +48,9 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/unified,target=/home/coder/.local,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/unified,target=/home/coder/.local,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda12.0-pip/features/utils/opt/devcontainer/bin,target=/opt/devcontainer/bin,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/.devcontainer/cuda12.0-pip/features/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/features/src/rapids-build-utils/devcontainer-feature.json b/features/src/rapids-build-utils/devcontainer-feature.json index 6e8a3e28..58e1a775 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": "23.10.3", + "version": "23.10.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/opt/rapids-build-utils/bin/generate-scripts.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/generate-scripts.sh index 85598009..7394de64 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/generate-scripts.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/generate-scripts.sh @@ -91,7 +91,7 @@ generate_cpp_scripts() { generate_python_scripts() { local script_name; - for script_name in "build" "clean"; do ( + for script_name in "build" "clean" "wheel"; do ( cat ${TMPL}/python-${script_name}.tmpl.sh \ | generate_script "${script_name}-${PY_LIB}-python"; ) || true; diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-jobs-and-archs.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-jobs-and-archs.sh index ee7bdbb5..465fd992 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-jobs-and-archs.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-jobs-and-archs.sh @@ -3,13 +3,24 @@ jobs_and_archs() { set -euo pipefail + local parallel=""; + + eval "$( \ + devcontainer-utils-parse-args --names ' + j|parallel | + ' - <<< "$@" \ + | xargs -r -d'\n' -I% echo -n local %\; \ + )"; + + parallel="${j:-${parallel:-}}"; + if [ "${parallel:-}" = "true" ]; then parallel=""; fi + local free_mem=$(free -g | head -n2 | tail -n1 | cut -d ':' -f2 | tr -s '[:space:]' | cut -d' ' -f7); - local max_cpus=$((free_mem / 4)); - local all_cpus=${JOBS:-${PARALLEL_LEVEL:-$(nproc --ignore=2)}}; - local n_jobs=$(( all_cpus < max_cpus ? all_cpus : max_cpus )); + local all_cpus="${parallel:-${JOBS:-${PARALLEL_LEVEL:-$(nproc --ignore=2)}}}"; + local n_jobs=$(( all_cpus < (free_mem / 4) ? all_cpus : (free_mem / 4) )); local archs; - archs=$(rapids-parse-cmake-var-from-args CMAKE_CUDA_ARCHITECTURES "$@"); + archs=$(rapids-parse-cmake-var-from-args CMAKE_CUDA_ARCHITECTURES "${__rest__[@]}"); archs="${archs:-${CMAKE_CUDA_ARCHITECTURES:-${CUDAARCHS:-}}}"; local n_archs=1; @@ -43,4 +54,8 @@ jobs_and_archs() { echo "n_arch=${n_archs}"; } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (jobs_and_archs "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-conda-env.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-conda-env.sh index 41ee0c7a..9a26fc38 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-conda-env.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-conda-env.sh @@ -14,13 +14,10 @@ make_conda_env() { fi local cuda_version="${CUDA_VERSION:-${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}}"; - cuda_version="$(echo "${cuda_version}" | cut -d'.' -f3 --complement)"; + cuda_version="$(cut -d'.' -f3 --complement <<< "${cuda_version}")"; - local python_version="${PYTHON_VERSION:-}"; - - if [ -z "${python_version}" ]; then - python_version="$(python3 --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f3 --complement)"; - fi + local python_version="${PYTHON_VERSION:-$(python3 --version 2>&1 | cut -d' ' -f2)}"; + python_version="$(cut -d'.' -f3 --complement <<< "${python_version}")"; local new_env_path="$(realpath -m /tmp/${env_file_name})"; local old_env_path="$(realpath -m ~/.conda/envs/${env_file_name})"; diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-pip-env.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-pip-env.sh index 401da1b1..552dbe81 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-pip-env.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/make-pip-env.sh @@ -14,13 +14,10 @@ make_pip_env() { fi local cuda_version="${CUDA_VERSION:-${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}}"; - cuda_version="$(echo "${cuda_version}" | cut -d'.' -f3 --complement)"; + cuda_version="$(cut -d'.' -f3 --complement <<< "${cuda_version}")"; - local python_version="${PYTHON_VERSION:-}"; - - if [ -z "${python_version}" ]; then - python_version="$(python3 --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f3 --complement)"; - fi + local python_version="${PYTHON_VERSION:-$(python3 --version 2>&1 | cut -d' ' -f2)}"; + python_version="$(cut -d'.' -f3 --complement <<< "${python_version}")"; local new_env_path="$(realpath -m /tmp/${env_file_name})"; local old_env_path="$(realpath -m ~/.local/share/venvs/${env_file_name})"; diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/build.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/build.tmpl.sh index e4292762..c541076d 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/build.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/build.tmpl.sh @@ -14,4 +14,8 @@ build_${NAME}() { done } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (build_${NAME} "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/clean.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/clean.tmpl.sh index 8371e544..9487d128 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/clean.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/clean.tmpl.sh @@ -14,4 +14,8 @@ clean_${NAME}() { done } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (clean_${NAME} "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/configure.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/configure.tmpl.sh index e3d2e37f..e8ebb4dc 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/configure.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/configure.tmpl.sh @@ -9,4 +9,8 @@ configure_${NAME}() { done } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (configure_${NAME} "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-build.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-build.tmpl.sh index cbc20545..39118f7c 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-build.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-build.tmpl.sh @@ -8,19 +8,35 @@ build_${CPP_LIB}_cpp() { exit 1; fi - configure-${CPP_LIB}-cpp "$@"; + local verbose=""; eval "$( \ - rapids-get-jobs-and-archs "$@" \ + devcontainer-utils-parse-args --names ' + v|verbose | + ' - <<< "$@" \ | xargs -r -d'\n' -I% echo -n local %\; \ )"; - time \ - JOBS="${n_jobs}" \ - PARALLEL_LEVEL="${n_jobs}" \ - cmake --build ~/${CPP_SRC}/build/latest \ - --parallel ${n_jobs} \ - --verbose; + verbose="${v:-${verbose:-}}"; + + if test -n "${verbose}"; then verbose="--log-level=VERBOSE"; fi + + configure-${CPP_LIB}-cpp ${verbose} ${__rest__[@]}; + + eval "$( \ + rapids-get-jobs-and-archs ${__rest__[@]} \ + | xargs -r -d'\n' -I% echo -n local %\; \ + )"; + + if test -n "${verbose}"; then verbose="--verbose"; fi + + time \ + JOBS="${n_jobs}" PARALLEL_LEVEL="${n_jobs}" \ + cmake --build ~/${CPP_SRC}/build/latest ${verbose} --parallel ${n_jobs}; } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (build_${CPP_LIB}_cpp "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-clean.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-clean.tmpl.sh index c3f78a94..da4b9dd1 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-clean.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-clean.tmpl.sh @@ -7,4 +7,8 @@ clean_${CPP_LIB}_cpp() { rm -rf ~/${CPP_SRC}/build/latest/*; } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (clean_${CPP_LIB}_cpp "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-configure.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-configure.tmpl.sh index 3ca42dfb..1120be8e 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-configure.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp-configure.tmpl.sh @@ -8,7 +8,18 @@ configure_${CPP_LIB}_cpp() { exit 1; fi - local build_type="$(rapids-parse-cmake-build-type "$@" | tr '[:upper:]' '[:lower:]')"; + local parallel=""; + + eval "$( \ + devcontainer-utils-parse-args --names ' + j|parallel | + ' - <<< "$@" \ + | xargs -r -d'\n' -I% echo -n local %\; \ + )"; + + parallel="${j:-${parallel:-}}"; + + local build_type="$(rapids-parse-cmake-build-type ${__rest__[@]} | tr '[:upper:]' '[:lower:]')"; local binary_dir=~/${CPP_SRC}/build/${build_type}; local source_dir=~/${CPP_SRC}; @@ -25,11 +36,11 @@ configure_${CPP_LIB}_cpp() { cmake_args+=(-B ${binary_dir}); cmake_args+=(${CPP_DEPS}); cmake_args+=(${CPP_ARGS}); - cmake_args+=(${@}); + cmake_args+=(${__rest__[@]}); - eval "$( \ - rapids-get-jobs-and-archs "$@" \ - | xargs -r -d'\n' -I% echo -n local %\; \ + eval "$( \ + rapids-get-jobs-and-archs -j${parallel} \ + | xargs -r -d'\n' -I% echo -n local %\; \ )"; time \ @@ -46,4 +57,8 @@ configure_${CPP_LIB}_cpp() { fi } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (configure_${CPP_LIB}_cpp "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-build.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-build.tmpl.sh index a08cf601..45bbd8fa 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-build.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-build.tmpl.sh @@ -8,28 +8,55 @@ build_${PY_LIB}_python() { exit 1; fi + local verbose="1"; + local parallel=""; + + eval "$( \ + devcontainer-utils-parse-args --names ' + j|parallel | + v|verbose | + ' - <<< "$@" \ + | xargs -r -d'\n' -I% echo -n local %\; \ + )"; + + verbose="${v:-${verbose:-}}"; + parallel="${j:-${parallel:-${JOBS:-${PARALLEL_LEVEL:-$(nproc --ignore=2)}}}}"; + local cmake_args=(); + if test -n "${verbose}"; then + cmake_args+=("--log-level=VERBOSE"); + fi + # Define both lowercase and uppercase # `-DFIND__CPP=ON` and `-DFIND__CPP=ON` because the RAPIDS # scikit-build CMakeLists.txt's aren't 100% consistent in the casing cmake_args+=(${CPP_DEPS}); cmake_args+=(${CPP_ARGS}); - cmake_args+=(${@}); + cmake_args+=(${__rest__[@]}); local ninja_args=(); - ninja_args+=("-v"); - ninja_args+=("-j${JOBS:-${PARALLEL_LEVEL:-$(nproc --ignore=2)}}"); + if test -n "${verbose}"; then + ninja_args+=("-v"); + fi + if test -n "${parallel}"; then + if [ "${parallel:-}" = "true" ]; then + parallel=""; + fi + ninja_args+=("-j${parallel}"); + fi local pip_args=(); - pip_args+=("-vv"); + if test -n "${verbose}"; then + pip_args+=("-vv"); + fi pip_args+=("--no-build-isolation"); pip_args+=("--no-deps"); pip_args+=("--editable"); - pip_args+=(~/${PY_SRC}); + pip_args+=(~/"${PY_SRC}"); cmake_args+=("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON"); - trap "rm -rf ~/${PY_SRC}/$(echo "${PY_LIB}" | tr '-' '_').egg-info" EXIT; + trap "rm -rf ~/'${PY_SRC}/$(echo "${PY_LIB}" | tr '-' '_').egg-info'" EXIT; time \ CMAKE_GENERATOR="Ninja" \ @@ -40,4 +67,8 @@ build_${PY_LIB}_python() { ; } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (build_${PY_LIB}_python "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-clean.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-clean.tmpl.sh index 0fa7562f..7564457d 100755 --- a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-clean.tmpl.sh +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-clean.tmpl.sh @@ -6,8 +6,19 @@ clean_${PY_LIB}_cpp() { local py_lib="$(tr '-' '_' <<< "${PY_LIB}")"; - rm -rf ~/"${PY_SRC}"/{build,_skbuild}; - rm -rf ~/"${PY_SRC}/${py_lib}.egg-info"; + rm -rf ~/"${PY_SRC}"/{_skbuild,${py_lib}.egg-info}; + + local python_version="${PYTHON_VERSION:-$(python3 --version 2>&1 | cut -d' ' -f2)}"; + python_version="$(cut -d'.' -f3 --complement <<< "${python_version}")"; + python_version="${python_version/./}"; + + local dir; + for dir in lib temp dist; do + local slug="${dir}.$(uname -s)-$(uname -m)-cpython-${python_version/./}"; + if test -d ~/"${PY_SRC}"/build/${slug,,}; then + rm -rf ~/"${PY_SRC}"/build/${slug,,}; + fi + done if test -d ~/"${PY_SRC}/${PY_LIB}"/; then find ~/"${PY_SRC}/${PY_LIB}"/ -type f \ @@ -22,4 +33,8 @@ clean_${PY_LIB}_cpp() { fi } +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + (clean_${PY_LIB}_cpp "$@"); diff --git a/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-wheel.tmpl.sh b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-wheel.tmpl.sh new file mode 100755 index 00000000..1a9f37d5 --- /dev/null +++ b/features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/python-wheel.tmpl.sh @@ -0,0 +1,114 @@ +#! /usr/bin/env bash + +build_${PY_LIB}_python() { + + set -euo pipefail; + + if [[ ! -d ~/${PY_SRC} ]]; then + exit 1; + fi + + local verbose="1"; + local parallel=""; + local wheel_dir=""; + + eval "$( \ + devcontainer-utils-parse-args --names ' + j|parallel | + v|verbose | + w|wheel-dir | + prefer-binary | + only-binary | + no-verify | + no-build-isolation | + no-deps | + no-use-pep517 | + ' - <<< "$@" \ + | xargs -r -d'\n' -I% echo -n local %\; \ + )"; + + verbose="${v:-${verbose:-}}"; + wheel_dir="${w:-${wheel_dir}}"; + parallel="${j:-${parallel:-${JOBS:-${PARALLEL_LEVEL:-$(nproc --ignore=2)}}}}"; + + local cmake_args=(); + + if test -n "${verbose}"; then + cmake_args+=("--log-level=VERBOSE"); + fi + + # Define both lowercase and uppercase + # `-DFIND__CPP=ON` and `-DFIND__CPP=ON` because the RAPIDS + # scikit-build CMakeLists.txt's aren't 100% consistent in the casing + cmake_args+=(${CPP_DEPS}); + cmake_args+=(${CPP_ARGS}); + cmake_args+=(${__rest__[@]}); + + local ninja_args=(); + if test -n "${verbose}"; then + ninja_args+=("-v"); + fi + if test -n "${parallel}"; then + if [ "${parallel:-}" = "true" ]; then + parallel=""; + fi + ninja_args+=("-j${parallel}"); + fi + + local pip_args=(); + if test -n "${verbose}"; then + pip_args+=("-vv"); + fi + + if test -n "${no_build_isolation:-}"; then + pip_args+=("--no-build-isolation"); + fi + + if test -n "${no_deps:-}"; then + pip_args+=("--no-deps"); + fi + + if test -n "${wheel_dir:-}"; then + pip_args+=("-w" "${wheel_dir}"); + fi + + if test -n "${prefer_binary:-}"; then + pip_args+=("--prefer-binary"); + if [ "${prefer_binary:-}" != "true" ]; then + pip_args+=("${prefer_binary:-}"); + fi + fi + + if test -n "${only_binary:-}"; then + pip_args+=("--only-binary"); + if [ "${only_binary:-}" != "true" ]; then + pip_args+=("${only_binary:-}"); + fi + fi + + if test -n "${no_verify:-}"; then + pip_args+=("--no-verify"); + fi + + if test -n "${no_use_pep517:-}"; then + pip_args+=("--no-use-pep517"); + fi + + + pip_args+=(~/"${PY_SRC}"); + + trap "rm -rf ~/'${PY_SRC}/${PY_LIB//-/_}.egg-info'" EXIT; + + time \ + CMAKE_GENERATOR="Ninja" \ + SKBUILD_BUILD_OPTIONS="${ninja_args[@]}" \ + CMAKE_ARGS="$(rapids-parse-cmake-args ${cmake_args[@]})" \ + python -m pip wheel ${pip_args[@]} \ + ; +} + +if test -n "${rapids_build_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi + +(build_${PY_LIB}_python "$@"); diff --git a/features/src/utils/opt/devcontainer/bin/parse-args.sh b/features/src/utils/opt/devcontainer/bin/parse-args.sh index 286aafc5..eaa5c5cb 100755 --- a/features/src/utils/opt/devcontainer/bin/parse-args.sh +++ b/features/src/utils/opt/devcontainer/bin/parse-args.sh @@ -7,10 +7,18 @@ parse_args() { local rest=(); declare -A dict; - local vars="^(.*)$"; + local vars="(.*)"; + local vars_array=(); if [ "${1:-}" = "--names" ]; then shift; - vars="^($(tr -d '[:space:]' <<< "${1}"))$"; + vars="$(tr -d '[:space:]' <<< "${1}")"; + vars_array=($(tr '|' ' ' <<< "${vars}")); + readarray -t vars_array < <( + for str in "${vars_array[@]}"; do + printf '%d\t%s\n' "${#str}" "$str" + done | sort -k 1,1nr -k 2 | cut -f 2- + ); + vars="(${vars})"; shift; fi @@ -24,7 +32,7 @@ parse_args() { # read args from stdin elif grep -qP '^-$' <<< "${arg:-}"; then shift; - set -- ${@} $(cat - | xargs -r echo); + eval set "-- $@ $(cat - | tr -s '[:space:]' | xargs -d'\n' -r echo -n)"; continue; # -- elif grep -qP '^--$' <<< "${arg:-}"; then @@ -41,25 +49,42 @@ parse_args() { # -foo bar | --foo bar elif grep -qP '^--?[^\s]+$' <<< "${arg:-}"; then shift; - key="${arg#-}"; - key="${key#-}"; - if ! grep -qE "^$" <<< "${1:-}"; then - if grep -qP '^-.*$' <<< "${1}"; then - val="true"; + # -fooval + local found=""; + if test "${#vars_array}" -gt 0 \ + && grep -qP "^--?${vars}([^\s])+$" <<< "${arg:-}"; then + for name in ${vars_array[@]}; do + if grep -qP "^--?${name}[0-9]+$" <<< "${arg:-}"; then + key="${name}"; + val="${arg#-}"; + val="${val#-}"; + val="${val#"${name}"}"; + found="1"; + break; + fi + done + fi + if test -z "${found}"; then + key="${arg#-}"; + key="${key#-}"; + if ! grep -qE "^$" <<< "${1:-}"; then + if grep -qP '^-.*$' <<< "${1}"; then + val="true"; + else + val="${1}"; + arg+=" ${val}"; + shift; + fi else - val="${1}"; - arg+=" ${val}"; - shift; + val="true"; fi - else - val="true"; fi else rest+=("${@}"); break; fi - if echo "${key}" | grep -qP "${vars}"; then + if echo "${key}" | grep -qP "^${vars}$"; then keys+=("${key}"); dict[$key]="$(printf %q "${val}")"; else @@ -83,8 +108,8 @@ parse_args() { echo "${keys[0]}=${dict[${keys[0]}]}"; } -# if test -n "${devcontainer_utils_debug:-}"; then -# PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; -# fi +if test -n "${devcontainer_utils_debug:-}"; then + PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; +fi (parse_args "$@"); diff --git a/image/.devcontainer/devcontainer.json b/image/.devcontainer/devcontainer.json index 092ac6e1..d0eaaa22 100644 --- a/image/.devcontainer/devcontainer.json +++ b/image/.devcontainer/devcontainer.json @@ -11,8 +11,8 @@ "workspaceFolder": "/home/coder", "features": { "ghcr.io/devcontainers/features/common-utils:2": { - "uid": "1000", - "gid": "1000", + "userUid": "1000", + "userGid": "1000", "username": "coder", "installZsh": "true", "upgradePackages": "true"