Skip to content

Commit 15c0466

Browse files
authored
Use rapids-build-backend. (#1502)
This PR uses `rapids-build-backend` to simplify wheel builds and reduce the complexity of various CI/build scripts. See also: - https://github.com/rapidsai/rapids-build-backend - rapidsai/build-planning#31 - rapidsai/cudf#15245 - #1529 Authors: - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Vyas Ramasubramani (https://github.com/vyasr) URL: #1502
1 parent f16de1f commit 15c0466

14 files changed

+121
-71
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/rapidsai/dependency-file-generator
9-
rev: v1.8.0
9+
rev: v1.13.11
1010
hooks:
1111
- id: rapids-dependency-file-generator
1212
args: ["--clean"]

build.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,9 @@ fi
170170
# Build and install the rmm Python package
171171
if (( NUMARGS == 0 )) || hasArg rmm; then
172172
echo "building and installing rmm..."
173-
SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm
173+
SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install \
174+
--no-build-isolation \
175+
--no-deps \
176+
--config-settings rapidsai.disable-cuda=true \
177+
${REPODIR}/python/rmm
174178
fi

ci/build_python.sh

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
2+
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
33

44
set -euo pipefail
55

@@ -13,20 +13,13 @@ export CMAKE_GENERATOR=Ninja
1313

1414
rapids-print-env
1515

16-
package_name="rmm"
17-
package_dir="python/rmm"
18-
19-
version=$(rapids-generate-version)
20-
commit=$(git rev-parse HEAD)
21-
22-
echo "${version}" > VERSION
23-
sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py"
16+
rapids-generate-version > ./VERSION
2417

2518
rapids-logger "Begin py build"
2619

2720
CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)
2821

2922
# This calls mambabuild when boa is installed (as is the case in the CI images)
30-
RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm
23+
RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm
3124

3225
rapids-upload-conda-to-s3 python

ci/build_wheel_cpp.sh

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,15 @@
33

44
set -euo pipefail
55

6-
package_name="librmm"
76
package_dir="python/librmm"
87

98
source rapids-configure-sccache
109
source rapids-date-string
1110

12-
version=$(rapids-generate-version)
13-
commit=$(git rev-parse HEAD)
11+
rapids-generate-version > ./VERSION
1412

1513
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
1614

17-
# This is the version of the suffix with a preceding hyphen. It's used
18-
# everywhere except in the final wheel name.
19-
PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}"
20-
21-
pyproject_file="${package_dir}/pyproject.toml"
22-
23-
sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
24-
echo "${version}" > VERSION
25-
sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py"
26-
2715
cd "${package_dir}"
2816

2917
python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check

ci/build_wheel_python.sh

+2-24
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,11 @@ package_dir="python/rmm"
99
source rapids-configure-sccache
1010
source rapids-date-string
1111

12-
version=$(rapids-generate-version)
13-
commit=$(git rev-parse HEAD)
14-
15-
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
16-
17-
# This is the version of the suffix with a preceding hyphen. It is used
18-
# everywhere except in the final wheel name.
19-
PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}"
20-
21-
pyproject_file="${package_dir}/pyproject.toml"
22-
23-
sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
24-
echo "${version}" > VERSION
25-
sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py"
26-
27-
alpha_spec=''
28-
if ! rapids-is-release-build; then
29-
alpha_spec=',>=0.0.0a0'
30-
fi
31-
32-
sed -r -i "s/librmm==(.*)\"/librmm${PACKAGE_CUDA_SUFFIX}==\1${alpha_spec}\"/g" ${pyproject_file}
33-
if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then
34-
sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file}
35-
fi
12+
rapids-generate-version > ./VERSION
3613

3714
cd "${package_dir}"
3815

16+
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
3917
CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist)
4018

4119
python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links "${CPP_WHEELHOUSE}"

conda/environments/all_cuda-118_arch-x86_64.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
33
channels:
44
- rapidsai
5+
- rapidsai-nightly
56
- conda-forge
67
dependencies:
78
- breathe>=4.35.0
@@ -32,7 +33,8 @@ dependencies:
3233
- pytest
3334
- pytest-cov
3435
- python>=3.9,<3.12
35-
- scikit-build-core>=0.7.0
36+
- rapids-build-backend >=0.3.0,<0.4.0.dev0
37+
- scikit-build-core >=0.7.0
3638
- spdlog>=1.12.0,<1.13
3739
- sphinx
3840
- sphinx-copybutton

conda/environments/all_cuda-122_arch-x86_64.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
33
channels:
44
- rapidsai
5+
- rapidsai-nightly
56
- conda-forge
67
dependencies:
78
- breathe>=4.35.0
@@ -31,7 +32,8 @@ dependencies:
3132
- pytest
3233
- pytest-cov
3334
- python>=3.9,<3.12
34-
- scikit-build-core>=0.7.0
35+
- rapids-build-backend >=0.3.0,<0.4.0.dev0
36+
- scikit-build-core >=0.7.0
3537
- spdlog>=1.12.0,<1.13
3638
- sphinx
3739
- sphinx-copybutton

conda/recipes/rmm/meta.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ requirements:
6262
- cuda-python >=12.0,<13.0a0
6363
{% endif %}
6464
- cython >=3.0.0
65+
- rapids-build-backend >=0.3.0,<0.4.0.dev0
6566
- librmm ={{ version }}
6667
- python
6768
- scikit-build-core >=0.7.0

dependencies.yaml

+31-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ files:
1414
- develop
1515
- docs
1616
- py_version
17+
- rapids_build_skbuild
1718
- run
1819
- test_python
1920
test_python:
@@ -43,13 +44,29 @@ files:
4344
pyproject_dir: python/librmm
4445
extras:
4546
table: build-system
47+
includes:
48+
- rapids_build_skbuild
49+
py_cpp_rapids_build:
50+
output: pyproject
51+
pyproject_dir: python/librmm
52+
extras:
53+
table: tool.rapids-build-backend
54+
key: requires
4655
includes:
4756
- build
4857
py_build:
4958
output: pyproject
5059
pyproject_dir: python/rmm
5160
extras:
5261
table: build-system
62+
includes:
63+
- rapids_build_skbuild
64+
py_rapids_build:
65+
output: pyproject
66+
pyproject_dir: python/rmm
67+
extras:
68+
table: tool.rapids-build-backend
69+
key: requires
5370
includes:
5471
- build
5572
- cython_build
@@ -70,8 +87,19 @@ files:
7087
- test_python
7188
channels:
7289
- rapidsai
90+
- rapidsai-nightly
7391
- conda-forge
7492
dependencies:
93+
rapids_build_skbuild:
94+
common:
95+
- output_types: conda
96+
packages:
97+
- rapids-build-backend >=0.3.0,<0.4.0.dev0
98+
- scikit-build-core >=0.7.0
99+
- output_types: [requirements, pyproject]
100+
packages:
101+
- rapids-build-backend>=0.3.0,<0.4.0.dev0
102+
- scikit-build-core[pyproject]>=0.7.0
75103
build:
76104
common:
77105
- output_types: [conda, requirements, pyproject]
@@ -83,11 +111,7 @@ dependencies:
83111
- c-compiler
84112
- cxx-compiler
85113
- fmt>=10.1.1,<11
86-
- scikit-build-core>=0.7.0
87114
- spdlog>=1.12.0,<1.13
88-
- output_types: [requirements, pyproject]
89-
packages:
90-
- scikit-build-core[pyproject]>=0.7.0
91115
specific:
92116
- output_types: conda
93117
matrices:
@@ -137,14 +161,14 @@ dependencies:
137161
- matrix:
138162
cuda: "12.*"
139163
packages:
140-
- librmm-cu12==24.8.*
164+
- librmm-cu12==24.8.*,>=0.0.0a0
141165
- matrix:
142166
cuda: "11.*"
143167
packages:
144-
- librmm-cu11==24.8.*
168+
- librmm-cu11==24.8.*,>=0.0.0a0
145169
- matrix:
146170
packages:
147-
- librmm==24.8.*
171+
- librmm==24.8.*,>=0.0.0a0
148172
checks:
149173
common:
150174
- output_types: [conda, requirements]

python/librmm/librmm/_version.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import importlib.resources
1616

1717
__version__ = (
18-
importlib.resources.files("librmm").joinpath("VERSION").read_text().strip()
18+
importlib.resources.files(__package__)
19+
.joinpath("VERSION")
20+
.read_text()
21+
.strip()
1922
)
2023
__git_commit__ = ""
24+
25+
__all__ = ["__git_commit__", "__version__"]

python/librmm/pyproject.toml

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
# limitations under the License.
1414

1515
[build-system]
16-
build-backend = "scikit_build_core.build"
16+
build-backend = "rapids_build_backend.build"
1717
requires = [
18-
"cmake>=3.26.4",
19-
"ninja",
18+
"rapids-build-backend>=0.3.0,<0.4.0.dev0",
2019
"scikit-build-core[pyproject]>=0.7.0",
2120
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
2221

@@ -44,6 +43,15 @@ Homepage = "https://github.com/rapidsai/rmm"
4443
[project.entry-points."cmake.prefix"]
4544
librmm = "librmm"
4645

46+
[tool.rapids-build-backend]
47+
build-backend = "scikit_build_core.build"
48+
commit-file = "librmm/GIT_COMMIT"
49+
dependencies-file = "../../dependencies.yaml"
50+
requires = [
51+
"cmake>=3.26.4",
52+
"ninja",
53+
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
54+
4755
[tool.scikit-build]
4856
build-dir = "build/{wheel_tag}"
4957
cmake.build-type = "Release"

python/rmm/pyproject.toml

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
# limitations under the License.
1414

1515
[build-system]
16-
build-backend = "scikit_build_core.build"
16+
build-backend = "rapids_build_backend.build"
1717
requires = [
18-
"cmake>=3.26.4",
19-
"cuda-python>=11.7.1,<12.0a0",
20-
"cython>=3.0.0",
21-
"librmm==24.8.*",
22-
"ninja",
18+
"rapids-build-backend>=0.3.0,<0.4.0.dev0",
2319
"scikit-build-core[pyproject]>=0.7.0",
2420
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
2521

@@ -125,6 +121,18 @@ provider = "scikit_build_core.metadata.regex"
125121
input = "rmm/VERSION"
126122
regex = "(?P<value>.*)"
127123

124+
[tool.rapids-build-backend]
125+
build-backend = "scikit_build_core.build"
126+
commit-file = "rmm/GIT_COMMIT"
127+
dependencies-file = "../../dependencies.yaml"
128+
requires = [
129+
"cmake>=3.26.4",
130+
"cuda-python>=11.7.1,<12.0a0",
131+
"cython>=3.0.0",
132+
"librmm==24.8.*,>=0.0.0a0",
133+
"ninja",
134+
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
135+
128136
[tool.pytest.ini_options]
129137
# treat warnings as errors
130138
filterwarnings = [

python/rmm/rmm/_version.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, NVIDIA CORPORATION.
1+
# Copyright (c) 2023-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.
@@ -15,6 +15,19 @@
1515
import importlib.resources
1616

1717
__version__ = (
18-
importlib.resources.files("rmm").joinpath("VERSION").read_text().strip()
18+
importlib.resources.files(__package__)
19+
.joinpath("VERSION")
20+
.read_text()
21+
.strip()
1922
)
20-
__git_commit__ = ""
23+
try:
24+
__git_commit__ = (
25+
importlib.resources.files(__package__)
26+
.joinpath("GIT_COMMIT")
27+
.read_text()
28+
.strip()
29+
)
30+
except FileNotFoundError:
31+
__git_commit__ = ""
32+
33+
__all__ = ["__git_commit__", "__version__"]

python/rmm/rmm/tests/test_version.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2024, NVIDIA CORPORATION.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# 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
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import rmm
16+
17+
18+
def test_version_constants_are_populated():
19+
# __git_commit__ will only be non-empty in a built distribution
20+
assert isinstance(rmm.__git_commit__, str)
21+
22+
# __version__ should always be non-empty
23+
assert isinstance(rmm.__version__, str)
24+
assert len(rmm.__version__) > 0

0 commit comments

Comments
 (0)