From 8626b8dc5d97c4842b8851a84f32dfab334a6523 Mon Sep 17 00:00:00 2001 From: Critsium Date: Thu, 23 Apr 2026 15:49:07 +0800 Subject: [PATCH] Allow selecting version --- docs/advanced/windows_installer.md | 5 +++++ tools/windows/README.md | 5 +++++ tools/windows/install-abacus.bat | 12 +++++++++++- tools/windows/provision.sh | 22 ++++++++++++++++++---- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/docs/advanced/windows_installer.md b/docs/advanced/windows_installer.md index 7d4e334676..c89dcfa238 100644 --- a/docs/advanced/windows_installer.md +++ b/docs/advanced/windows_installer.md @@ -20,6 +20,9 @@ The pipeline, end to end: - Checks the Windows build (≥ 19041) and whether WSL is installed; if not, runs `wsl --install --no-launch` and asks the user to reboot once. - Optionally enables TUNA (Tsinghua) mirrors for users in Mainland China. + - Prompts for an ABACUS version (blank = latest on conda-forge; an exact + version like `3.7.4` is pinned; a match-spec like `>=3.7,<3.8` is passed + through to conda). - Detects the target distribution (`Ubuntu-22.04`) by querying the WSL registry key `HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`. This is immune to UTF-16 parsing pitfalls and to Store appx leftovers that @@ -88,6 +91,8 @@ The pipeline, end to end: 1. Clone or download this repository. 2. In `tools/windows/`, right-click `install-abacus.bat` → **Run as administrator**. 3. Answer the China-mirror prompt (`y` recommended inside Mainland China). + Then pick an ABACUS version when prompted (leave blank for the latest on + conda-forge; for a pinned install, type an exact version such as `3.7.4`). 4. If this is the first time WSL is installed on the machine, the script will ask you to reboot and run it again. 5. Wait for `[*] Provisioning ABACUS …` to finish (5–15 minutes on first diff --git a/tools/windows/README.md b/tools/windows/README.md index 1bf5769971..ef56582130 100644 --- a/tools/windows/README.md +++ b/tools/windows/README.md @@ -17,6 +17,9 @@ The pipeline, end to end: - Checks the Windows build (≥ 19041) and whether WSL is installed; if not, runs `wsl --install --no-launch` and asks the user to reboot once. - Optionally enables TUNA (Tsinghua) mirrors for users in Mainland China. + - Prompts for an ABACUS version (blank = latest on conda-forge; an exact + version like `3.7.4` is pinned; a match-spec like `>=3.7,<3.8` is passed + through to conda). - Detects the target distribution (`Ubuntu-22.04`) by querying the WSL registry key `HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`. This is immune to UTF-16 parsing pitfalls and to Store appx leftovers that @@ -85,6 +88,8 @@ The pipeline, end to end: 1. Clone or download this repository. 2. Right-click `install-abacus.bat` → **Run as administrator**. 3. Answer the China-mirror prompt (`y` recommended inside Mainland China). + Then pick an ABACUS version when prompted (leave blank for the latest on + conda-forge; for a pinned install, type an exact version such as `3.7.4`). 4. If this is the first time WSL is installed on the machine, the script will ask you to reboot and run it again. 5. Wait for `[*] Provisioning ABACUS …` to finish (5–15 minutes on first diff --git a/tools/windows/install-abacus.bat b/tools/windows/install-abacus.bat index 2af99d09eb..64219b6ccf 100644 --- a/tools/windows/install-abacus.bat +++ b/tools/windows/install-abacus.bat @@ -35,6 +35,16 @@ if not defined ABACUS_CHINA_MIRROR ( if /i "!CHINA_INPUT!"=="y" set "ABACUS_CHINA_MIRROR=1" ) +REM --- 2c. Optional ABACUS version pin (blank = latest from conda-forge) --- +if not defined ABACUS_VERSION ( + echo. + echo Which ABACUS version would you like to install? + echo - Leave blank to install the latest available on conda-forge. + echo - Or enter an exact version, e.g. 3.7.4 + echo - You can also enter a conda match-spec, e.g. "^>=3.7,^<3.8" + set /p ABACUS_VERSION="ABACUS version [latest]: " +) + REM --- 3. Ensure WSL itself is present --- where wsl >nul 2>&1 if errorlevel 1 ( @@ -108,7 +118,7 @@ if not defined WSL_SCRIPT ( REM Strip any CR bytes that a Windows editor / git autocrlf may have injected REM into provision.sh, then pipe the cleaned script into bash. Without this, REM bash reads `set -euo pipefail\r` and errors on the literal \r. -wsl -d %DISTRO% -u root -- bash -c "sed 's/\r$//' '!WSL_SCRIPT!' | ABACUS_CHINA_MIRROR=!ABACUS_CHINA_MIRROR! bash" +wsl -d %DISTRO% -u root -- bash -c "sed 's/\r$//' '!WSL_SCRIPT!' | ABACUS_CHINA_MIRROR=!ABACUS_CHINA_MIRROR! ABACUS_VERSION='!ABACUS_VERSION!' bash" if errorlevel 1 ( echo [!] Provisioning failed. See output above. pause & exit /b 1 diff --git a/tools/windows/provision.sh b/tools/windows/provision.sh index 2007243c48..03b95cb759 100644 --- a/tools/windows/provision.sh +++ b/tools/windows/provision.sh @@ -8,6 +8,18 @@ MINIFORGE_DIR="/opt/abacus-miniforge" ENV_NAME="abacus_env" ENV_BIN="$MINIFORGE_DIR/envs/$ENV_NAME/bin" CHINA_MIRROR="${ABACUS_CHINA_MIRROR:-0}" +VERSION_SPEC="${ABACUS_VERSION:-}" + +# Build the conda match-spec. Empty => latest; a bare version like "3.7.4" +# is pinned with "="; anything containing an operator (>=, <, etc.) or a +# comma is passed through as-is. +if [ -z "$VERSION_SPEC" ]; then + ABACUS_PKG="abacus" +elif echo "$VERSION_SPEC" | grep -qE '[<>=!,* ]'; then + ABACUS_PKG="abacus $VERSION_SPEC" +else + ABACUS_PKG="abacus=$VERSION_SPEC" +fi if [ "$CHINA_MIRROR" = "1" ]; then MINIFORGE_URL="https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh" @@ -62,11 +74,13 @@ fi source "$MINIFORGE_DIR/etc/profile.d/conda.sh" if conda env list | awk 'NF && $1 !~ /^#/ {print $1}' | grep -qx "$ENV_NAME"; then - log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL)..." - conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" abacus + log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." + # shellcheck disable=SC2086 + conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG else - log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL)..." - conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" abacus + log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." + # shellcheck disable=SC2086 + conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG fi log "Installing system launchers..."