Skip to content

Commit 67aa283

Browse files
committed
feat: add rapids-artifact-name for standardized artifact naming
1 parent 568fb09 commit 67aa283

1 file changed

Lines changed: 165 additions & 0 deletions

File tree

tools/rapids-artifact-name

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#!/bin/bash
2+
# Generates a standardized artifact name following the template:
3+
# {repo}_{pkg_type}_{pkg_lang}_{pkg_name}_{cpython_version}_{cuda_version}_{arch}
4+
# Positional Arguments:
5+
# 1) package type (conda_cpp, conda_python, wheel_cpp, wheel_python)
6+
# 2) package name (e.g. librmm, rmm)
7+
# 3) repo_name (optional): overrides repo name derived from RAPIDS_REPOSITORY
8+
# Flags:
9+
# --cuda [version]: CUDA version as cu<N> (bare: uses RAPIDS_CUDA_VERSION)
10+
# --py [version]: Python version as cp<NNN> (bare: uses RAPIDS_PY_VERSION)
11+
# (python packages only; mutually exclusive with --stable and --pure)
12+
# --stable: use abi3 for cpython_version (python packages only)
13+
# --pure: use pure for cpython_version (python packages only)
14+
set -euo pipefail
15+
export RAPIDS_SCRIPT_NAME="rapids-artifact-name"
16+
17+
cuda_flag=0
18+
py_flag=0
19+
stable_flag=0
20+
pure_flag=0
21+
cuda_version=""
22+
py_version=""
23+
pkg_type=""
24+
pkg_name=""
25+
repo_name=""
26+
27+
while [[ $# -gt 0 ]]; do
28+
case $1 in
29+
--cuda)
30+
cuda_flag=1
31+
shift
32+
if [[ $# -gt 0 && "$1" != -* ]]; then
33+
cuda_version="$1"
34+
shift
35+
fi
36+
;;
37+
--py)
38+
py_flag=1
39+
shift
40+
if [[ $# -gt 0 && "$1" != -* ]]; then
41+
py_version="$1"
42+
shift
43+
fi
44+
;;
45+
--stable)
46+
stable_flag=1
47+
shift
48+
;;
49+
--pure)
50+
pure_flag=1
51+
shift
52+
;;
53+
-*)
54+
rapids-echo-stderr "Unknown flag: $1. Supported flags: --cuda, --py, --stable, --pure"
55+
exit 1
56+
;;
57+
*)
58+
if [[ -z "${pkg_type}" ]]; then
59+
pkg_type="$1"
60+
shift
61+
elif [[ -z "${pkg_name}" ]]; then
62+
pkg_name="$1"
63+
shift
64+
elif [[ -z "${repo_name}" ]]; then
65+
repo_name="$1"
66+
shift
67+
else
68+
rapids-echo-stderr "Too many positional arguments: $1"
69+
exit 1
70+
fi
71+
;;
72+
esac
73+
done
74+
75+
if [[ -z "${pkg_type}" || -z "${pkg_name}" ]]; then
76+
rapids-echo-stderr "Usage: rapids-artifact-name PKG_TYPE PKG_NAME [REPO_NAME] --cuda [version] [--py [version] | --stable | --pure]"
77+
exit 1
78+
fi
79+
80+
case "${pkg_type}" in
81+
conda_cpp|conda_python|wheel_cpp|wheel_python) ;;
82+
*)
83+
rapids-echo-stderr "Invalid package type '${pkg_type}'. Must be one of: conda_cpp, conda_python, wheel_cpp, wheel_python"
84+
exit 1
85+
;;
86+
esac
87+
88+
pkg_type_part="${pkg_type%%_*}"
89+
pkg_lang="${pkg_type##*_}"
90+
91+
if (( stable_flag == 1 && pure_flag == 1 )); then
92+
rapids-echo-stderr "Cannot use '--stable' with '--pure'"
93+
exit 1
94+
fi
95+
96+
if (( stable_flag == 1 && py_flag == 1 )); then
97+
rapids-echo-stderr "Cannot use '--stable' with '--py'"
98+
exit 1
99+
fi
100+
101+
if (( pure_flag == 1 && py_flag == 1 )); then
102+
rapids-echo-stderr "Cannot use '--pure' with '--py'"
103+
exit 1
104+
fi
105+
106+
if [[ "${pkg_lang}" == "cpp" ]] && (( stable_flag == 1 || pure_flag == 1 )); then
107+
rapids-echo-stderr "'--stable' and '--pure' are only valid for Python package types"
108+
exit 1
109+
fi
110+
111+
if [[ "${pkg_lang}" == "python" ]] && (( stable_flag == 0 && pure_flag == 0 && py_flag == 0 )); then
112+
rapids-echo-stderr "Python packages require one of: --py [version], --stable, --pure"
113+
exit 1
114+
fi
115+
116+
if [[ -z "${repo_name}" ]]; then
117+
repo_name="${RAPIDS_REPOSITORY##*/}"
118+
fi
119+
120+
# Resolve CUDA version (only when --cuda flag was passed)
121+
cuda_field=""
122+
if (( cuda_flag == 1 )); then
123+
if [[ -z "${cuda_version}" ]]; then
124+
if [[ -z "${RAPIDS_CUDA_VERSION:-}" ]]; then
125+
rapids-echo-stderr "RAPIDS_CUDA_VERSION must be set when using --cuda without a version argument"
126+
exit 1
127+
fi
128+
cuda_version="${RAPIDS_CUDA_VERSION}"
129+
fi
130+
cuda_field="cu${cuda_version%%.*}"
131+
fi
132+
133+
# Resolve cpython_version field
134+
if [[ "${pkg_lang}" == "cpp" ]]; then
135+
cpython_version="pure"
136+
elif (( stable_flag == 1 )); then
137+
cpython_version="abi3"
138+
elif (( pure_flag == 1 )); then
139+
cpython_version="pure"
140+
else
141+
if [[ -z "${py_version}" ]]; then
142+
if [[ -z "${RAPIDS_PY_VERSION:-}" ]]; then
143+
rapids-echo-stderr "RAPIDS_PY_VERSION must be set when using --py without a version argument"
144+
exit 1
145+
fi
146+
py_version="${RAPIDS_PY_VERSION}"
147+
fi
148+
cpython_version="cp${py_version//./}"
149+
fi
150+
151+
# Resolve arch field
152+
raw_arch="$(arch)"
153+
case "${raw_arch}" in
154+
x86_64) arch_field="amd64" ;;
155+
aarch64) arch_field="arm64" ;;
156+
*) arch_field="${raw_arch}" ;;
157+
esac
158+
159+
artifact_name="${repo_name}_${pkg_type_part}_${pkg_lang}_${pkg_name}_${cpython_version}"
160+
if [[ -n "${cuda_field}" ]]; then
161+
artifact_name+="_${cuda_field}"
162+
fi
163+
artifact_name+="_${arch_field}"
164+
165+
echo -n "${artifact_name}"

0 commit comments

Comments
 (0)