From 89d7c2b30d888dc686bd97231cf9f532a83dd4e4 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 28 Oct 2024 09:32:59 -0500 Subject: [PATCH] build wheels without build isolation, print sccache stats in builds (#792) Contributes to https://github.com/rapidsai/build-planning/issues/108 Contributes to https://github.com/rapidsai/build-planning/issues/111 Proposes some small packaging/CI changes, matching similar changes being made across RAPIDS. * removes the use of build isolation in wheel builds * printing `sccache` stats to CI logs * reducing `pip`'s verbosity in wheel building scripts * using the RAPIDS conventions `py_build_{project}` and `py_rapids_build_{project}` in `dependencies.yaml` * updating to the latest `rapids-dependency-file-generator` (v1.16.0) Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cucim/pull/792 --- .pre-commit-config.yaml | 2 +- ci/build_cpp.sh | 4 ++++ ci/build_python.sh | 4 ++++ ci/build_wheel.sh | 36 ++++++++++++++++++++++++++++-------- dependencies.yaml | 4 ++-- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b912cf46a..62765dd93 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: hooks: - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.13.11 + rev: v1.16.0 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 9b419b816..2a347b7e5 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -17,6 +17,10 @@ rapids-logger "Begin cpp build" conda config --set path_conflict prevent +sccache --zero-stats + RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/libcucim +sccache --show-adv-stats + rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index 25925f906..4c942e096 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -20,6 +20,8 @@ conda config --set path_conflict prevent CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +sccache --zero-stats + # TODO: Remove `--no-test` flag once importing on a CPU # node works correctly RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild \ @@ -27,4 +29,6 @@ RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild \ --channel "${CPP_CHANNEL}" \ conda/recipes/cucim +sccache --show-adv-stats + rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 4005c36d4..c72dd9467 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -5,7 +5,6 @@ set -euo pipefail package_name="cucim" package_dir="python/cucim" -package_src_dir="${package_dir}/src/${package_name}" CMAKE_BUILD_TYPE="release" @@ -16,21 +15,42 @@ rapids-generate-version > ./VERSION RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" +rapids-logger "Generating build requirements" -# Install pip build dependencies (not yet using pyproject.toml) rapids-dependency-file-generator \ - --file-key "py_build" \ - --output "requirements" \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee build_requirements.txt -pip install -r build_requirements.txt + --output requirements \ + --file-key "py_build_${package_name}" \ + --file-key "py_rapids_build_${package_name}" \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" \ +| tee /tmp/requirements-build.txt + +rapids-logger "Installing build requirements" +python -m pip install \ + -v \ + --prefer-binary \ + -r /tmp/requirements-build.txt + +sccache --zero-stats # First build the C++ lib using CMake via the run script ./run build_local all ${CMAKE_BUILD_TYPE} +sccache --show-adv-stats + cd "${package_dir}" -python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check +sccache --zero-stats + +rapids-logger "Building '${package_name}' wheel" +python -m pip wheel \ + -w dist \ + -v \ + --no-build-isolation \ + --no-deps \ + --disable-pip-version-check \ + . + +sccache --show-adv-stats mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* diff --git a/dependencies.yaml b/dependencies.yaml index e25c6f909..5ffab20b2 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -31,14 +31,14 @@ files: - cuda_version - docs - py_version - py_build: + py_build_cucim: output: pyproject pyproject_dir: python/cucim extras: table: build-system includes: - rapids_build_setuptools - py_rapids_build: + py_rapids_build_cucim: output: pyproject pyproject_dir: python/cucim extras: