Skip to content

Commit

Permalink
Remove hard-coding of RAPIDS version where possible (#1357)
Browse files Browse the repository at this point in the history
* Read `VERSION` file in CMake
* Read `cuspatial.__version__` and `cuproj.__version__` in docs build
* Read `VERSION` file in shell scripts
* Use environment variable substitution in Doxygen
* Remove updates from `ci/release/update-version.sh`

Issue: rapidsai/build-planning#15

Authors:
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Jake Awe (https://github.com/AyodeAwe)
  - Mark Harris (https://github.com/harrism)

URL: #1357
  • Loading branch information
KyleFromNVIDIA authored Mar 12, 2024
1 parent 6298419 commit f410685
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 82 deletions.
6 changes: 4 additions & 2 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -euo pipefail

Expand Down Expand Up @@ -27,7 +27,9 @@ rapids-mamba-retry install \
cuspatial \
cuproj

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 cuSpatial CPP docs"
Expand Down
25 changes: 1 addition & 24 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#############################
# cuSpatial Version Updater #
#############################
Expand Down Expand Up @@ -29,33 +30,9 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

# python/cpp update
sed_runner 's/'"CUSPATIAL VERSION .* LANGUAGES"'/'"CUSPATIAL VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt
sed_runner 's/'"CUPROJ VERSION .* LANGUAGES"'/'"CUPROJ VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/cuproj/CMakeLists.txt
sed_runner 's/'"cuspatial_version .*)"'/'"cuspatial_version ${NEXT_FULL_TAG})"'/g' python/cuspatial/CMakeLists.txt
sed_runner 's/'"cuproj_version .*)"'/'"cuproj_version ${NEXT_FULL_TAG})"'/g' python/cuproj/CMakeLists.txt
sed_runner 's/'"cuproj_version .*)"'/'"cuproj_version ${NEXT_FULL_TAG})"'/g' python/cuproj/cuproj/cuprojshim/CMakeLists.txt

# RTD update
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/source/conf.py
sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/source/conf.py
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/cuproj/source/conf.py
sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/cuproj/source/conf.py

# 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

# Doxyfile update - cuspatial
sed_runner "/PROJECT_NUMBER[ ]*=/ s|=.*|= ${NEXT_FULL_TAG}|g" cpp/doxygen/Doxyfile
sed_runner "/TAGFILES/ s|[0-9]\+.[0-9]\+|${NEXT_SHORT_TAG}|g" cpp/doxygen/Doxyfile

#Doxyfile update - cuproj
sed_runner "/PROJECT_NUMBER[ ]*=/ s|=.*|= ${NEXT_FULL_TAG}|g" cpp/cuproj/doxygen/Doxyfile
sed_runner "/TAGFILES/ s|[0-9]\+.[0-9]\+|${NEXT_SHORT_TAG}|g" cpp/cuproj/doxygen/Doxyfile

# CI files
for FILE in .github/workflows/*.yaml; do
sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
Expand Down
8 changes: 4 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-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.
Expand All @@ -16,7 +16,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../fetch_rapids.cmake)
include(../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -25,7 +25,7 @@ include(rapids-find)

rapids_cuda_init_architectures(CUSPATIAL)

project(CUSPATIAL VERSION 24.04.00 LANGUAGES C CXX CUDA)
project(CUSPATIAL VERSION "${RAPIDS_VERSION}" LANGUAGES C CXX CUDA)

# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
Expand Down Expand Up @@ -296,7 +296,7 @@ if(DOXYGEN_FOUND)
add_custom_command(
OUTPUT CUSPATIAL_DOXYGEN
WORKING_DIRECTORY ${CUSPATIAL_SOURCE_DIR}/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
COMMAND ${CMAKE_COMMAND} -E env "RAPIDS_VERSION=${RAPIDS_VERSION}" "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}" ${DOXYGEN_EXECUTABLE} Doxyfile
VERBATIM
COMMENT "Custom command for building cuspatial doxygen docs."
)
Expand Down
8 changes: 4 additions & 4 deletions cpp/cuproj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-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.
Expand All @@ -16,7 +16,7 @@

cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -25,7 +25,7 @@ include(rapids-find)

rapids_cuda_init_architectures(CUPROJ)

project(CUPROJ VERSION 24.04.00 LANGUAGES C CXX CUDA)
project(CUPROJ VERSION "${RAPIDS_VERSION}" LANGUAGES C CXX CUDA)

# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
Expand Down Expand Up @@ -237,7 +237,7 @@ if(DOXYGEN_FOUND)
add_custom_command(
OUTPUT CUPROJ_DOXYGEN
WORKING_DIRECTORY ${CUPROJ_SOURCE_DIR}/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
COMMAND ${CMAKE_COMMAND} -E env "RAPIDS_VERSION=${RAPIDS_VERSION}" "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}" ${DOXYGEN_EXECUTABLE} Doxyfile
VERBATIM
COMMENT "Custom command for building cuproj doxygen docs."
)
Expand Down
4 changes: 2 additions & 2 deletions cpp/cuproj/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = libcuproj
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 24.04.00
PROJECT_NUMBER = $(RAPIDS_VERSION)

# 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
Expand Down Expand Up @@ -2345,7 +2345,7 @@ SKIP_FUNCTION_MACROS = YES
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.

TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/24.04 "libcudf.tag=https://docs.rapids.ai/api/libcudf/24.04"
TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/$(RAPIDS_VERSION_MAJOR_MINOR) "libcudf.tag=https://docs.rapids.ai/api/libcudf/$(RAPIDS_VERSION_MAJOR_MINOR)"

# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
Expand Down
4 changes: 2 additions & 2 deletions cpp/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "libcuspatial"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 24.04.00
PROJECT_NUMBER = $(RAPIDS_VERSION)

# 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
Expand Down Expand Up @@ -2171,7 +2171,7 @@ SKIP_FUNCTION_MACROS = YES
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.

TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/24.04 "libcudf.tag=https://docs.rapids.ai/api/libcudf/24.04"
TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/$(RAPIDS_VERSION_MAJOR_MINOR) "libcudf.tag=https://docs.rapids.ai/api/libcudf/$(RAPIDS_VERSION_MAJOR_MINOR)"

# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
Expand Down
11 changes: 8 additions & 3 deletions docs/cuproj/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

from packaging.version import Version

import cuproj

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
Expand Down Expand Up @@ -49,10 +53,11 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
CUPROJ_VERSION = Version(cuproj.__version__)
# The short X.Y version.
version = '24.04'
version = f"{CUPROJ_VERSION.major:02}.{CUPROJ_VERSION.minor:02}"
# The full version, including alpha/beta/rc tags.
release = '24.04.00'
release = f"{CUPROJ_VERSION.major:02}.{CUPROJ_VERSION.minor:02}.{CUPROJ_VERSION.micro:02}"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
11 changes: 8 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

from packaging.version import Version

import cuspatial

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
Expand Down Expand Up @@ -49,10 +53,11 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
CUSPATIAL_VERSION = Version(cuspatial.__version__)
# The short X.Y version.
version = '24.04'
version = f"{CUSPATIAL_VERSION.major:02}.{CUSPATIAL_VERSION.minor:02}"
# The full version, including alpha/beta/rc tags.
release = '24.04.00'
release = f"{CUSPATIAL_VERSION.major:02}.{CUSPATIAL_VERSION.minor:02}.{CUSPATIAL_VERSION.micro:02}"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
19 changes: 0 additions & 19 deletions fetch_rapids.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions java/src/main/native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-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.
Expand All @@ -15,7 +15,7 @@
#=============================================================================
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../../../../fetch_rapids.cmake)
include(../../../../rapids_config.cmake)

# TODO: The logic for setting the architectures was previously not here. Was
# that just an oversight, or is there a reason not to include this here?
Expand Down
10 changes: 4 additions & 6 deletions python/cuproj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-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
Expand All @@ -14,23 +14,21 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cuproj_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)
include(rapids-cuda)
rapids_cuda_init_architectures(cuproj-python)

project(
cuproj-python
VERSION ${cuproj_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA)

option(FIND_CUPROJ_CPP "Search for existing cuproj C++ installations before defaulting to local files"
OFF)

# If the user requested it we attempt to find cuproj.
if(FIND_CUPROJ_CPP)
find_package(cuproj ${cuproj_version})
find_package(cuproj "${RAPIDS_VERSION}")
else()
set(cuproj_FOUND OFF)
endif()
Expand Down
8 changes: 3 additions & 5 deletions python/cuproj/cuproj/cuprojshim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-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
Expand All @@ -14,9 +14,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cuproj_version 24.04.00)

include(../../../../fetch_rapids.cmake)
include(../../../../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -26,7 +24,7 @@ rapids_cuda_init_architectures(CUPROJSHIM)

project(
CUPROJSHIM
VERSION ${cuproj_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA)


Expand Down
10 changes: 4 additions & 6 deletions python/cuspatial/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-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
Expand All @@ -14,23 +14,21 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cuspatial_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)
include(rapids-cuda)
rapids_cuda_init_architectures(cuspatial-python)

project(
cuspatial-python
VERSION ${cuspatial_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA)

option(FIND_CUSPATIAL_CPP "Search for existing cuspatial C++ installations before defaulting to local files"
OFF)

# If the user requested it we attempt to find cuspatial.
if(FIND_CUSPATIAL_CPP)
find_package(cuspatial ${cuspatial_version})
find_package(cuspatial "${RAPIDS_VERSION}")
else()
set(cuspatial_FOUND OFF)
endif()
Expand Down
36 changes: 36 additions & 0 deletions rapids_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# =============================================================================
# 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}/CUSPATIAL_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}/CUSPATIAL_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake"
)
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/CUSPATIAL_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")

0 comments on commit f410685

Please sign in to comment.