From 2cb1ac7ffe85443492abc5529eb32d0277abe74d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 8 Mar 2024 09:33:47 -0500 Subject: [PATCH] Remove hard-coding of RAPIDS version where possible (#1496) * Read `VERSION` file from CMake * Read `rmm.__version__` from docs build * Read `VERSION` file from shell scripts * Remove updates from `ci/release/update-version.sh` Issue: https://github.com/rapidsai/build-planning/issues/15 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1496 --- CMakeLists.txt | 7 ++++--- ci/build_docs.sh | 4 +++- ci/check_style.sh | 3 ++- ci/release/update-version.sh | 19 ------------------- doxygen/Doxyfile | 2 +- fetch_rapids.cmake | 18 ------------------ python/CMakeLists.txt | 8 +++----- python/docs/conf.py | 11 +++++++++-- rapids_config.cmake | 34 ++++++++++++++++++++++++++++++++++ scripts/doxygen.sh | 3 +++ 10 files changed, 59 insertions(+), 50 deletions(-) delete mode 100644 fetch_rapids.cmake create mode 100644 rapids_config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 086069b09..56454d4b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -include(fetch_rapids.cmake) +include(rapids_config.cmake) include(rapids-cmake) include(rapids-cpm) @@ -23,7 +23,7 @@ include(rapids-find) project( RMM - VERSION 24.04.00 + VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) # Write the version header @@ -173,7 +173,8 @@ rapids_export( add_custom_command( OUTPUT RMM_DOXYGEN WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen - COMMAND doxygen Doxyfile + COMMAND ${CMAKE_COMMAND} -E env "RAPIDS_VERSION=${RAPIDS_VERSION}" + "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}" doxygen Doxyfile VERBATIM COMMENT "Custom command for RMM doxygen docs") diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 1979e9a2c..d5be5d33b 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,9 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="24.04" +export RAPIDS_VERSION="$(rapids-version)" +export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index 66c7e36f3..860cd56f9 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,8 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/cmake-format-rapids-cmake.json +RAPIDS_VERSION_NUMBER="$(rapids-version-major-minor)" +FORMAT_FILE_URL="https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_NUMBER}/cmake-format-rapids-cmake.json" export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index b7ea5892f..2a6e550df 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,28 +32,9 @@ function sed_runner() { sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak } -# cpp update -sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt - -# Python update -sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt - # Centralized version file update echo "${NEXT_FULL_TAG}" > VERSION -# rapids-cmake version -sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake - -# cmake-format rapids-cmake definitions -sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh - -# doxyfile update -sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile - -# sphinx docs update -sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py -sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py - # CI files for FILE in .github/workflows/*.yaml; do sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index d1a5e8869..a5c183236 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = RMM # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 24.04 +PROJECT_NUMBER = $(RAPIDS_VERSION_MAJOR_MINOR) # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake deleted file mode 100644 index 684b1e140..000000000 --- a/fetch_rapids.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# ============================================================================= -# Copyright (c) 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. -# ============================================================================= -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) -endif() -include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6a7490133..87752ff24 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,13 +14,11 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 24.04.00) - -include(../fetch_rapids.cmake) +include(../rapids_config.cmake) project( rmm-python - VERSION ${rmm_version} + VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" @@ -28,7 +26,7 @@ option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting # If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) - find_package(rmm ${rmm_version}) + find_package(rmm "${RAPIDS_VERSION}") else() set(rmm_FOUND OFF) endif() diff --git a/python/docs/conf.py b/python/docs/conf.py index 3595a8f36..d66e9d30c 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -13,6 +13,10 @@ import os import re +from packaging.version import Version + +import rmm + # -- Project information ----------------------------------------------------- project = "rmm" @@ -23,10 +27,13 @@ # |version| and |release|, also used in various other places throughout the # built documents. # +RMM_VERSION = Version(rmm.__version__) # The short X.Y version. -version = "24.04" +version = f"{RMM_VERSION.major:02}.{RMM_VERSION.minor:02}" # The full version, including alpha/beta/rc tags. -release = "24.04.00" +release = ( + f"{RMM_VERSION.major:02}.{RMM_VERSION.minor:02}.{RMM_VERSION.micro:02}" +) # -- General configuration --------------------------------------------------- diff --git a/rapids_config.cmake b/rapids_config.cmake new file mode 100644 index 000000000..84c20c01e --- /dev/null +++ b/rapids_config.cmake @@ -0,0 +1,34 @@ +# ============================================================================= +# Copyright (c) 2018-2024, 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. +# ============================================================================= +file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version) +if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]]) + set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}") + set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}") + set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}") + set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}") +else() + string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}") + message( + FATAL_ERROR + "Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}") +endif() + +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") + file( + DOWNLOAD + "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") +endif() +include("${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") diff --git a/scripts/doxygen.sh b/scripts/doxygen.sh index c584723ae..372a9f27d 100755 --- a/scripts/doxygen.sh +++ b/scripts/doxygen.sh @@ -21,6 +21,9 @@ if [ ! $(version "$DOXYGEN_VERSION") -eq $(version "1.9.1") ] ; then exit 0 fi +export RAPIDS_VERSION="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2.\3/' VERSION)" +export RAPIDS_VERSION_MAJOR_MINOR="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2/' VERSION)" + # Run doxygen, ignore missing tag files error TAG_ERROR1="error: Tag file '.*.tag' does not exist or is not a file. Skipping it..." TAG_ERROR2="error: cannot open tag file .*.tag for writing"