Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/advanced/windows_installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tools/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tools/windows/install-abacus.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions tools/windows/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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..."
Expand Down
Loading