Skip to content

Commit 29b51c7

Browse files
authored
Allow selecting version (#7278)
1 parent 5c617c7 commit 29b51c7

4 files changed

Lines changed: 39 additions & 5 deletions

File tree

docs/advanced/windows_installer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ The pipeline, end to end:
2020
- Checks the Windows build (≥ 19041) and whether WSL is installed; if not,
2121
runs `wsl --install --no-launch` and asks the user to reboot once.
2222
- Optionally enables TUNA (Tsinghua) mirrors for users in Mainland China.
23+
- Prompts for an ABACUS version (blank = latest on conda-forge; an exact
24+
version like `3.7.4` is pinned; a match-spec like `>=3.7,<3.8` is passed
25+
through to conda).
2326
- Detects the target distribution (`Ubuntu-22.04`) by querying the WSL
2427
registry key `HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`. This
2528
is immune to UTF-16 parsing pitfalls and to Store appx leftovers that
@@ -88,6 +91,8 @@ The pipeline, end to end:
8891
1. Clone or download this repository.
8992
2. In `tools/windows/`, right-click `install-abacus.bat` → **Run as administrator**.
9093
3. Answer the China-mirror prompt (`y` recommended inside Mainland China).
94+
Then pick an ABACUS version when prompted (leave blank for the latest on
95+
conda-forge; for a pinned install, type an exact version such as `3.7.4`).
9196
4. If this is the first time WSL is installed on the machine, the script
9297
will ask you to reboot and run it again.
9398
5. Wait for `[*] Provisioning ABACUS …` to finish (5–15 minutes on first

tools/windows/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ The pipeline, end to end:
1717
- Checks the Windows build (≥ 19041) and whether WSL is installed; if not,
1818
runs `wsl --install --no-launch` and asks the user to reboot once.
1919
- Optionally enables TUNA (Tsinghua) mirrors for users in Mainland China.
20+
- Prompts for an ABACUS version (blank = latest on conda-forge; an exact
21+
version like `3.7.4` is pinned; a match-spec like `>=3.7,<3.8` is passed
22+
through to conda).
2023
- Detects the target distribution (`Ubuntu-22.04`) by querying the WSL
2124
registry key `HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`. This
2225
is immune to UTF-16 parsing pitfalls and to Store appx leftovers that
@@ -85,6 +88,8 @@ The pipeline, end to end:
8588
1. Clone or download this repository.
8689
2. Right-click `install-abacus.bat` → **Run as administrator**.
8790
3. Answer the China-mirror prompt (`y` recommended inside Mainland China).
91+
Then pick an ABACUS version when prompted (leave blank for the latest on
92+
conda-forge; for a pinned install, type an exact version such as `3.7.4`).
8893
4. If this is the first time WSL is installed on the machine, the script
8994
will ask you to reboot and run it again.
9095
5. Wait for `[*] Provisioning ABACUS …` to finish (5–15 minutes on first

tools/windows/install-abacus.bat

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ if not defined ABACUS_CHINA_MIRROR (
3535
if /i "!CHINA_INPUT!"=="y" set "ABACUS_CHINA_MIRROR=1"
3636
)
3737

38+
REM --- 2c. Optional ABACUS version pin (blank = latest from conda-forge) ---
39+
if not defined ABACUS_VERSION (
40+
echo.
41+
echo Which ABACUS version would you like to install?
42+
echo - Leave blank to install the latest available on conda-forge.
43+
echo - Or enter an exact version, e.g. 3.7.4
44+
echo - You can also enter a conda match-spec, e.g. "^>=3.7,^<3.8"
45+
set /p ABACUS_VERSION="ABACUS version [latest]: "
46+
)
47+
3848
REM --- 3. Ensure WSL itself is present ---
3949
where wsl >nul 2>&1
4050
if errorlevel 1 (
@@ -108,7 +118,7 @@ if not defined WSL_SCRIPT (
108118
REM Strip any CR bytes that a Windows editor / git autocrlf may have injected
109119
REM into provision.sh, then pipe the cleaned script into bash. Without this,
110120
REM bash reads `set -euo pipefail\r` and errors on the literal \r.
111-
wsl -d %DISTRO% -u root -- bash -c "sed 's/\r$//' '!WSL_SCRIPT!' | ABACUS_CHINA_MIRROR=!ABACUS_CHINA_MIRROR! bash"
121+
wsl -d %DISTRO% -u root -- bash -c "sed 's/\r$//' '!WSL_SCRIPT!' | ABACUS_CHINA_MIRROR=!ABACUS_CHINA_MIRROR! ABACUS_VERSION='!ABACUS_VERSION!' bash"
112122
if errorlevel 1 (
113123
echo [!] Provisioning failed. See output above.
114124
pause & exit /b 1

tools/windows/provision.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ MINIFORGE_DIR="/opt/abacus-miniforge"
88
ENV_NAME="abacus_env"
99
ENV_BIN="$MINIFORGE_DIR/envs/$ENV_NAME/bin"
1010
CHINA_MIRROR="${ABACUS_CHINA_MIRROR:-0}"
11+
VERSION_SPEC="${ABACUS_VERSION:-}"
12+
13+
# Build the conda match-spec. Empty => latest; a bare version like "3.7.4"
14+
# is pinned with "="; anything containing an operator (>=, <, etc.) or a
15+
# comma is passed through as-is.
16+
if [ -z "$VERSION_SPEC" ]; then
17+
ABACUS_PKG="abacus"
18+
elif echo "$VERSION_SPEC" | grep -qE '[<>=!,* ]'; then
19+
ABACUS_PKG="abacus $VERSION_SPEC"
20+
else
21+
ABACUS_PKG="abacus=$VERSION_SPEC"
22+
fi
1123

1224
if [ "$CHINA_MIRROR" = "1" ]; then
1325
MINIFORGE_URL="https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh"
@@ -62,11 +74,13 @@ fi
6274
source "$MINIFORGE_DIR/etc/profile.d/conda.sh"
6375

6476
if conda env list | awk 'NF && $1 !~ /^#/ {print $1}' | grep -qx "$ENV_NAME"; then
65-
log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL)..."
66-
conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" abacus
77+
log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..."
78+
# shellcheck disable=SC2086
79+
conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG
6780
else
68-
log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL)..."
69-
conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" abacus
81+
log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..."
82+
# shellcheck disable=SC2086
83+
conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG
7084
fi
7185

7286
log "Installing system launchers..."

0 commit comments

Comments
 (0)