Skip to content

Commit e899c68

Browse files
authored
Expose the version string in C++ and Python (rapidsai#666)
Closes rapidsai#663 Depends on rapidsai#665 * Expose C++ macros `RMM_VER_MAJOR` and `RMM_VER_MINOR` to encode the major and minor versions of RMM. This is useful for downstream packages that links with RMM in the C++ layer. * Expose the version string via `rmm.__version__`, to follow a widely-recognized convention for accessing version of Python modules. Authors: - Philip Hyunsu Cho (@hcho3) Approvers: - Ashwin Srinath (@shwina) - @jakirkham - Keith Kraus (@kkraus14) - Mark Harris (@harrism) URL: rapidsai#666
1 parent 1502058 commit e899c68

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

CMakeLists.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# Copyright (c) 2018, NVIDIA CORPORATION.
2+
# Copyright (c) 2018-2021, 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
@@ -20,6 +20,10 @@ project(
2020

2121
include(cmake/Modules/CPM.cmake)
2222
include(cmake/Modules/RMM_thirdparty.cmake)
23+
include(cmake/Modules/Version.cmake)
24+
25+
# Write the version header
26+
write_version()
2327

2428
# build type
2529

@@ -53,8 +57,10 @@ find_package(CUDAToolkit REQUIRED)
5357
add_library(rmm INTERFACE)
5458
add_library(rmm::rmm ALIAS rmm)
5559

56-
target_include_directories(rmm INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
57-
"$<INSTALL_INTERFACE:include>")
60+
target_include_directories(
61+
rmm
62+
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
63+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>" "$<INSTALL_INTERFACE:include>")
5864

5965
if(CUDA_STATIC_RUNTIME)
6066
message(STATUS "RMM: Enabling static linking of cudart")
@@ -98,6 +104,8 @@ set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/rmm)
98104
install(TARGETS rmm EXPORT rmm-targets)
99105

100106
install(DIRECTORY include/rmm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
107+
install(FILES ${RMM_BINARY_DIR}/include/rmm/version_config.hpp
108+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rmm)
101109

102110
include(CMakePackageConfigHelpers)
103111
configure_package_config_file(cmake/rmm-config.cmake.in ${RMM_BINARY_DIR}/rmm-config.cmake

cmake/Modules/Version.cmake

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2021, NVIDIA CORPORATION.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
# in compliance with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations under
11+
# the License.
12+
13+
# Generate version_config.hpp from the version found in CMakeLists.txt
14+
function(write_version)
15+
message(STATUS "RMM VERSION: ${RMM_VERSION}")
16+
configure_file(${RMM_SOURCE_DIR}/cmake/version_config.hpp.in
17+
${RMM_BINARY_DIR}/include/rmm/version_config.hpp @ONLY)
18+
endfunction(write_version)

cmake/version_config.hpp.in

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2021, NVIDIA CORPORATION.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#pragma once
17+
18+
#define RMM_VERSION_MAJOR @RMM_VERSION_MAJOR@
19+
#define RMM_VERSION_MINOR @RMM_VERSION_MINOR@
20+
#define RMM_VERSION_PATCH @RMM_VERSION_PATCH@

python/rmm/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018-2019, NVIDIA CORPORATION.
1+
# Copyright (c) 2018-2021, 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.
@@ -24,3 +24,7 @@
2424
reinitialize,
2525
rmm_cupy_allocator,
2626
)
27+
28+
from rmm._version import get_versions
29+
30+
__version__ = get_versions()["version"]

0 commit comments

Comments
 (0)