Skip to content

Commit 2d7dfe9

Browse files
committed
toolshed: take python_major_minor as an argument and align variable naming
Make the Python version a required argument to both helpers instead of deriving it from the CUDA major. The previous case/switch over the CUDA major was a brittle source of truth: every time a new Python or CUDA line was supported, the helper would silently install the wrong Python until it was updated. Pushing the choice to the caller keeps the helpers focused on the conda environment they manage and lets the caller pick whatever Python they actually want to test against. New usage on both platforms is parallel: conda_create_for_pathfinder_testing.sh 3.12 12.9.2 conda_create_for_pathfinder_testing.ps1 3.12 12.9.2 Variable / parameter names now match the usage line and read identically across the two scripts: - bash: ``python_major_minor`` / ``cuda_major_minor_patch`` - PowerShell: ``$PythonMajorMinor`` / ``$CudaMajorMinorPatch`` The PowerShell ``param()`` block uses ``Mandatory + Position 0/1`` so the script accepts both positional invocation (matching the bash style above) and the named ``-PythonMajorMinor`` / ``-CudaMajorMinorPatch`` form. Switch the ``libcudla-dev`` gate from ``cuda_major == "13"`` to ``(( cuda_major >= 13 ))`` so future CUDA majors fall through to the correct branch automatically. ``(( ))`` is the idiomatic bash form for integer comparison; the script is already firmly bash-only (``#!/bin/bash``, ``set -euo pipefail``), so the syntax is in keeping with the rest of the file.
1 parent 76d2524 commit 2d7dfe9

2 files changed

Lines changed: 14 additions & 33 deletions

File tree

toolshed/conda_create_for_pathfinder_testing.ps1

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
param(
5-
[Parameter(Mandatory = $true)]
6-
[string]$CudaVersion
5+
[Parameter(Mandatory = $true, Position = 0)]
6+
[string]$PythonMajorMinor,
7+
[Parameter(Mandatory = $true, Position = 1)]
8+
[string]$CudaMajorMinorPatch
79
)
810

911
$ErrorActionPreference = "Stop"
1012
Set-StrictMode -Version Latest
1113

12-
$cudaMajor = $CudaVersion.Split(".", 2)[0]
13-
switch ($cudaMajor) {
14-
"12" { $pythonVersion = "3.12" }
15-
"13" { $pythonVersion = "3.14" }
16-
default {
17-
throw "Unsupported CUDA major version for this helper: $cudaMajor. Expected a 12.x or 13.x toolkit version."
18-
}
19-
}
20-
2114
& "$env:CONDA_EXE" "shell.powershell" "hook" | Out-String | Invoke-Expression
2215

23-
conda create --yes -n "pathfinder_testing_cu$CudaVersion" "python=$pythonVersion" "cuda-toolkit=$CudaVersion"
24-
conda activate "pathfinder_testing_cu$CudaVersion"
16+
conda create --yes -n "pathfinder_testing_cu$CudaMajorMinorPatch" "python=$PythonMajorMinor" "cuda-toolkit=$CudaMajorMinorPatch"
17+
conda activate "pathfinder_testing_cu$CudaMajorMinorPatch"
2518

2619
# Keep this list aligned with the Windows-installable subset of
2720
# cuda_pathfinder/pyproject.toml.

toolshed/conda_create_for_pathfinder_testing.sh

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,21 @@
55

66
set -euo pipefail
77

8-
if [[ $# -ne 1 ]]; then
9-
echo "Usage: $(basename "$0") ctk-major-minor-patch" 1>&2
8+
if [[ $# -ne 2 ]]; then
9+
echo "Usage: $(basename "$0") python_major_minor cuda_major_minor_patch" 1>&2
1010
exit 1
1111
fi
1212

13-
cuda_version="$1"
14-
cuda_major="${cuda_version%%.*}"
13+
python_major_minor="$1"
14+
cuda_major_minor_patch="$2"
15+
cuda_major="${cuda_major_minor_patch%%.*}"
1516
uname_m="$(uname -m)"
16-
case "$cuda_major" in
17-
12)
18-
python_version=3.12
19-
;;
20-
13)
21-
python_version=3.14
22-
;;
23-
*)
24-
echo "Unsupported CUDA major version for this helper: $cuda_major" 1>&2
25-
echo "Expected a 12.x or 13.x toolkit version." 1>&2
26-
exit 1
27-
;;
28-
esac
2917

3018
eval "$(conda shell.bash hook)"
3119

32-
conda create --yes -n "pathfinder_testing_cu$cuda_version" "python=$python_version" cuda-toolkit="$cuda_version"
20+
conda create --yes -n "pathfinder_testing_cu$cuda_major_minor_patch" "python=$python_major_minor" cuda-toolkit="$cuda_major_minor_patch"
3321
set +u
34-
conda activate "pathfinder_testing_cu$cuda_version"
22+
conda activate "pathfinder_testing_cu$cuda_major_minor_patch"
3523
set -u
3624

3725
# Keep this list aligned with the Linux-installable subset of
@@ -52,7 +40,7 @@ cpkgs=(
5240
# Keep the conda environment aligned with platform-scoped pyproject groups.
5341
if [[ "$uname_m" == "aarch64" ]]; then
5442
cpkgs+=("libnvpl-fft-dev")
55-
if [[ "$cuda_major" == "13" ]]; then
43+
if (( cuda_major >= 13 )); then
5644
cpkgs+=("libcudla-dev")
5745
fi
5846
fi

0 commit comments

Comments
 (0)