Skip to content

Commit dc66ff9

Browse files
Remove hard-coding of RAPIDS version where possible (#5793)
* Read `VERSION` file from CMake * Read `cuml.__version__` from docs build * Read `VERSION` file from `ci/build_docs.sh` Issue: rapidsai/build-planning#15 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) - Jake Awe (https://github.com/AyodeAwe) URL: #5793
1 parent bf89f08 commit dc66ff9

9 files changed

+57
-53
lines changed

ci/build_docs.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2023, NVIDIA CORPORATION.
2+
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
33
set -euo pipefail
44

55
rapids-logger "Create test conda environment"
@@ -25,7 +25,9 @@ rapids-mamba-retry install \
2525
--channel "${PYTHON_CHANNEL}" \
2626
cuml libcuml
2727

28-
export RAPIDS_VERSION_NUMBER="24.04"
28+
export RAPIDS_VERSION="$(rapids-version)"
29+
export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)"
30+
export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR"
2931
export RAPIDS_DOCS_DIR="$(mktemp -d)"
3032

3133
rapids-logger "Build CPP docs"

ci/release/update-version.sh

-19
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,6 @@ sed_runner "s/cudf==.*\",/cudf==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/pyprojec
4444
sed_runner "s/pylibraft==.*\",/pylibraft==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/pyproject.toml
4545
sed_runner "s/raft-dask==.*\",/raft-dask==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/pyproject.toml
4646

47-
48-
# CMakeLists
49-
sed_runner 's/'"CUML VERSION .* LANGUAGES"'/'"CUML VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt
50-
sed_runner 's/'"set(CUML_VERSION .*)"'/'"set(CUML_VERSION ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt
51-
52-
# rapids-cmake version
53-
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake
54-
55-
56-
# RTD update
57-
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/source/conf.py
58-
sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/source/conf.py
59-
60-
# Update project_number (RAPIDS_VERSION) in the CPP doxygen file
61-
sed_runner "s/\(PROJECT_NUMBER.*=\).*/\1 \"${NEXT_SHORT_TAG}\"/g" cpp/Doxyfile.in
62-
63-
# Wheel testing script
64-
sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" ci/test_wheel.sh
65-
6647
DEPENDENCIES=(
6748
cudf
6849
cuml

cpp/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=============================================================================
2-
# Copyright (c) 2018-2023 NVIDIA CORPORATION.
2+
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)
1818

19-
include(../fetch_rapids.cmake)
19+
include(../rapids_config.cmake)
2020

2121
include(rapids-cmake)
2222
include(rapids-cpm)
@@ -26,7 +26,7 @@ include(rapids-find)
2626

2727
rapids_cuda_init_architectures(CUML)
2828

29-
project(CUML VERSION 24.04.00 LANGUAGES CXX CUDA)
29+
project(CUML VERSION "${RAPIDS_VERSION}" LANGUAGES CXX CUDA)
3030

3131
# Write the version header
3232
rapids_cmake_write_version_file(include/cuml/version_config.hpp)

cpp/Doxyfile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "cuML C++ API"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = "24.04"
41+
PROJECT_NUMBER = "$(RAPIDS_VERSION_MAJOR_MINOR)"
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

cpp/cmake/doxygen.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ function(add_doxygen_target)
2323
cmake_parse_arguments(dox "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
2424
configure_file(${dox_IN_DOXYFILE} ${dox_OUT_DOXYFILE} @ONLY)
2525
add_custom_target(docs_cuml
26+
${CMAKE_COMMAND} -E env "RAPIDS_VERSION=${RAPIDS_VERSION}" "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}"
2627
${DOXYGEN_EXECUTABLE} ${dox_OUT_DOXYFILE}
2728
WORKING_DIRECTORY ${dox_CWD}
2829
VERBATIM

docs/source/conf.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
2+
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
33
#
44
# This file is execfile()d with the current directory set to its
55
# containing dir.
@@ -17,6 +17,10 @@
1717
import os
1818
import sys
1919

20+
from packaging.version import Version
21+
22+
import cuml
23+
2024
# If extensions (or modules to document with autodoc) are in another
2125
# directory, add these directories to sys.path here. If the directory
2226
# is relative to the documentation root, use os.path.abspath to make it
@@ -76,10 +80,11 @@
7680
# |version| and |release|, also used in various other places throughout the
7781
# built documents.
7882
#
83+
CUML_VERSION = Version(cuml.__version__)
7984
# The short X.Y version.
80-
version = '24.04'
85+
version = f"{CUML_VERSION.major:02}.{CUML_VERSION.minor:02}"
8186
# The full version, including alpha/beta/rc tags.
82-
release = '24.04.00'
87+
release = f"{CUML_VERSION.major:02}.{CUML_VERSION.minor:02}.{CUML_VERSION.micro:02}"
8388

8489
# The language for content autogenerated by Sphinx. Refer to documentation
8590
# for a list of supported languages.

fetch_rapids.cmake

-19
This file was deleted.

python/CMakeLists.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# Copyright (c) 2022-2023 NVIDIA CORPORATION.
2+
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
# in compliance with the License. You may obtain a copy of the License at
@@ -14,9 +14,7 @@
1414

1515
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)
1616

17-
include(../fetch_rapids.cmake)
18-
19-
set(CUML_VERSION 24.04.00)
17+
include(../rapids_config.cmake)
2018

2119
option(CUML_CPU "Build only cuML CPU Python components." OFF)
2220
set(language_list "CXX")
@@ -31,7 +29,7 @@ endif()
3129

3230
project(
3331
cuml-python
34-
VERSION ${CUML_VERSION}
32+
VERSION "${RAPIDS_VERSION}"
3533
LANGUAGES ${language_list}
3634
)
3735

rapids_config.cmake

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# =============================================================================
2+
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License. You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed under the License
10+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
# or implied. See the License for the specific language governing permissions and limitations under
12+
# the License.
13+
# =============================================================================
14+
file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version)
15+
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
16+
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
17+
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
18+
set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}")
19+
set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}")
20+
set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}")
21+
else()
22+
string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}")
23+
message(
24+
FATAL_ERROR
25+
"Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}"
26+
)
27+
endif()
28+
29+
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/CUML_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
30+
file(
31+
DOWNLOAD
32+
"https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake"
33+
"${CMAKE_CURRENT_BINARY_DIR}/CUML_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake"
34+
)
35+
endif()
36+
include("${CMAKE_CURRENT_BINARY_DIR}/CUML_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")

0 commit comments

Comments
 (0)