Skip to content

Commit

Permalink
Remove hard-coding of RAPIDS version where possible (#351)
Browse files Browse the repository at this point in the history
* Add `VERSION` file
* Read `VERSION` file from CMake
* Read `VERSION` file from Python
* Read `kvikio.__version__` from docs build
* Read `VERSION` file from shell scripts
* Use variable substitution in Doxyfile
* Remove unused `ci/checks/style.sh`
* Update `ci/release/update-version.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)
  - Vukasin Milovanovic (https://github.com/vuule)
  - https://github.com/jakirkham

URL: #351
  • Loading branch information
KyleFromNVIDIA authored Mar 12, 2024
1 parent 787a6a3 commit af9bad8
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 83 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.04.00
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 All @@ -25,7 +25,9 @@ rapids-mamba-retry install \
--channel "${PYTHON_CHANNEL}" \
kvikio libkvikio

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"
Expand Down
6 changes: 4 additions & 2 deletions ci/check_style.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
# Copyright (c) 2020-2024, NVIDIA CORPORATION.

set -euo pipefail

Expand All @@ -14,7 +14,9 @@ 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-23.04/cmake-format-rapids-cmake.json
RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)"

FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/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}
Expand Down
19 changes: 0 additions & 19 deletions ci/checks/style.sh

This file was deleted.

27 changes: 2 additions & 25 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,13 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

# cpp update
sed_runner "/project(/,/)/s/VERSION.*/VERSION ${NEXT_FULL_TAG}/" cpp/CMakeLists.txt

# Python CMakeLists updates
sed_runner 's/set(kvikio_version.*)/set(kvikio_version '${NEXT_FULL_TAG}')/g' python/CMakeLists.txt

# Python __init__.py updates
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/kvikio/__init__.py

# Python pyproject.toml updates
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pyproject.toml

# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' cpp/cmake/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/checks/style.sh

# doxyfile update
sed_runner 's/PROJECT_NUMBER = .*/PROJECT_NUMBER = '${NEXT_FULL_TAG}'/g' cpp/doxygen/Doxyfile

# sphinx docs 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
# Centralized version file update
echo "${NEXT_FULL_TAG}" > VERSION

# CI files
for FILE in .github/workflows/*.yaml; do
sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
done
sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh

# .devcontainer files
find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do
Expand Down
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(cmake/fetch_rapids.cmake)
include(cmake/rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-export)
include(rapids-find)

project(
KvikIO
VERSION 24.04.00
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX
)

Expand Down
19 changes: 0 additions & 19 deletions cpp/cmake/fetch_rapids.cmake

This file was deleted.

36 changes: 36 additions & 0 deletions cpp/cmake/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}/KVIKIO_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}/KVIKIO_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake"
)
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/KVIKIO_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
2 changes: 1 addition & 1 deletion cpp/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "libkvikio"
# 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
11 changes: 8 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved.
# See file LICENSE for terms.
#
# Configuration file for the Sphinx documentation builder.
Expand All @@ -17,16 +17,21 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

from packaging.version import Version

import kvikio

# -- Project information -----------------------------------------------------

project = "kvikio"
copyright = "2023, NVIDIA"
author = "NVIDIA"

KVIKIO_VERSION = Version(kvikio.__version__)
# The short X.Y version.
version = '24.04'
version = f"{KVIKIO_VERSION.major:02}.{KVIKIO_VERSION.minor:02}"
# The full version, including alpha/beta/rc tags
release = '24.04.00'
release = f"{KVIKIO_VERSION.major:02}.{KVIKIO_VERSION.minor:02}.{KVIKIO_VERSION.micro:02}"


# -- General configuration ---------------------------------------------------
Expand Down
10 changes: 4 additions & 6 deletions python/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,17 +14,15 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(kvikio_version 24.04.00)

include(../cpp/cmake/fetch_rapids.cmake)
include(../cpp/cmake/rapids_config.cmake)
include(rapids-cpm)
rapids_cpm_init()
include(rapids-cuda)
rapids_cuda_init_architectures(kvikio-python)

project(
kvikio-python
VERSION ${kvikio_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA
)

Expand All @@ -36,7 +34,7 @@ option(FIND_KVIKIO_CPP
include(../cpp/cmake/Modules/FindcuFile.cmake)

if(FIND_KVIKIO_CPP)
find_package(KvikIO ${kvikio_version})
find_package(KvikIO "${RAPIDS_VERSION}")
else()
set(KvikIO_FOUND OFF)
endif()
Expand Down
1 change: 1 addition & 0 deletions python/kvikio/VERSION
5 changes: 2 additions & 3 deletions python/kvikio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
# See file LICENSE for terms.

from ._lib import libkvikio # type: ignore
from ._version import __version__ # noqa: F401
from .cufile import CuFile # noqa: F401

__version__ = "24.04.00"


def memory_register(buf) -> None:
return libkvikio.memory_register(buf)
Expand Down
20 changes: 20 additions & 0 deletions python/kvikio/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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
#
# 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.

import importlib.resources

__version__ = (
importlib.resources.files("kvikio").joinpath("VERSION").read_text().strip()
)
__git_commit__ = ""
7 changes: 6 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires = [

[project]
name = "kvikio"
version = "24.04.00"
dynamic = ["version"]
description = "KvikIO - GPUDirect Storage"
readme = { file = "README.md", content-type = "text/markdown" }
authors = [
Expand Down Expand Up @@ -117,3 +117,8 @@ ninja.make-fallback = true
sdist.exclude = ["*tests*"]
sdist.reproducible = true
wheel.packages = ["kvikio"]

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "kvikio/VERSION"
regex = "(?P<value>.*)"

0 comments on commit af9bad8

Please sign in to comment.