Skip to content
Open
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ docs/_build/

# Application specific
*.dmg
*.app
*.app

# Locally cached release assets (installers)
release_assets/dtu-miniconda
release_assets/vsCode
2 changes: 2 additions & 0 deletions Core/Conda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
curl -fsSL https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main/Core/Conda/install/install_macOS.sh | bash
```

Optionally set the `PS_FORGE_URL` to specify the source of the Miniforge

## Uninstall (macOS)

```bash
Expand Down
34 changes: 17 additions & 17 deletions Core/Conda/install/install_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@

set -euo pipefail

#BASE_URL="https://github.com/philipnickel/miniforge-PIS/releases/latest/download"

BASE_URL="https://github.com/dtudk/pythonsupport-forge/releases/latest/download" #TODO: change to internal site
#https://github.com/dtudk/pythonsupport-forge

ARCH="$(uname -m)"
INSTALLER_NAME="Miniforge3-MacOSX-${ARCH}.sh"
INSTALL_DIR="$HOME/miniforge3-dtu"
PS_FORGE_URL="${PS_FORGE_URL:-https://github.com/dtudk/pythonsupport-forge/releases/latest/download}" #TODO: change to internal site
arch="$(uname -m)"
installer_name="Miniforge3-MacOSX-${arch}.sh"
install_dir="$HOME/miniforge3-dtu"

echo "=== Installing Miniforge ==="
echo ""

# Check if already installed
if [ -d "$INSTALL_DIR" ] && [ -x "$INSTALL_DIR/bin/conda" ]; then
echo " Miniforge is already installed at $INSTALL_DIR"
if [ -d "$install_dir" ] && [ -x "$install_dir/bin/conda" ]; then
echo " Miniforge is already installed at $install_dir"
echo " [OK] Skipping download"
else
# Download
TMPDIR_PATH="$(mktemp -d)"
trap "rm -rf '$TMPDIR_PATH'" EXIT
tmpdir_path="$(mktemp -d)"
trap "rm -rf '$tmpdir_path'" EXIT

echo " Downloading ${INSTALLER_NAME}..."
curl -fSL "${BASE_URL}/${INSTALLER_NAME}" -o "$TMPDIR_PATH/${INSTALLER_NAME}"
echo " Downloading ${installer_name}..."
curl -fSL "${PS_FORGE_URL}/${installer_name}" -o "$tmpdir_path/${installer_name}"
echo " [OK] Download complete"

# Run installer in batch mode (no prompts, no PATH modification)
echo " Running installer..."
bash "$TMPDIR_PATH/${INSTALLER_NAME}" -buc -p "$INSTALL_DIR"
echo " [OK] Miniforge installed to $INSTALL_DIR"
# Installer options:
# '-b': run non interactively
# '-u': update an existing installation if there is one
# '-c': don't modify shell rc files
bash "$tmpdir_path/${installer_name}" -buc -p "$install_dir"
echo " [OK] Miniforge installed to $install_dir"
fi

# Load conda shell functions and activate the base environment
echo " Initializing conda..."
. "${INSTALL_DIR}/etc/profile.d/conda.sh" && conda activate "${INSTALL_DIR}"
source "${install_dir}/etc/profile.d/conda.sh" && conda activate "${install_dir}"

# Initialize conda for all supported shells on this machine
conda init --all
Expand Down
73 changes: 73 additions & 0 deletions Core/Conda/install/install_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# @doc
# @name: Miniforge Install (Windows)
# @description: Download and install Miniforge (conda) on Windows
# @category: Core
# @usage: powershell -File Core/Conda/install/install_windows.ps1
# @requirements: Windows, PowerShell 5.1+
# @notes: Downloads the latest Miniforge installer and runs it silently.
# The installer bundles Python and all required course packages.
# @/doc

$ErrorActionPreference = "Stop"

$PS_FORGE_URL = $env:PS_FORGE_URL
if (-not $PS_FORGE_URL) { $PS_FORGE_URL = "https://github.com/dtudk/pythonsupport-forge/releases/latest/download" } #TODO: change to internal site
$installerName = "Miniforge3-Windows-x86_64.exe"
$installDir = Join-Path $env:USERPROFILE "miniforge3-dtu"
$condaExe = Join-Path $installDir "Scripts\conda.exe"


Write-Host "=== Installing Miniforge ===`n"

# Check if already installed
if (Test-Path $condaExe) {
Write-Host " Miniforge is already installed at $installDir"
Write-Host " [OK] Skipping download"
} else {
$tmpDir = $null
try {
$tmpDir = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ("miniforge_" + [System.Guid]::NewGuid())
$installerPath = Join-Path $tmpDir.FullName $installerName

Write-Host " Downloading $installerName..."
Invoke-WebRequest -Uri "$PS_FORGE_URL/$installerName" -OutFile $installerPath -UseBasicParsing
Write-Host " [OK] Download complete"

# Run installer
# Flag rules per the constructor docs
# (https://conda.github.io/constructor/cli-options/#windows-installers):
Write-Host " Running installer..."
$argString = "/S /InstallationType=JustMe /RegisterPython=0 /AddToPath=0 /D=$installDir"
$proc = Start-Process -FilePath $installerPath -ArgumentList $argString `
-NoNewWindow -Wait -PassThru
if ($proc.ExitCode -ne 0) {
throw "Miniforge installer exited with code $($proc.ExitCode)"
}
Write-Host " [OK] Miniforge installed to $installDir"
}
finally {
if ($tmpDir -and (Test-Path $tmpDir.FullName)) {
Remove-Item -Recurse -Force $tmpDir.FullName -ErrorAction SilentlyContinue
}
}
}

#NOTE: Not needed if we just use miniconda prompt
# Load conda shell integration and activate the base environment
# (mirror of 'source conda.sh && conda activate' in the macOS script)
#Write-Host " Initializing conda..."
#$condaHook = Join-Path $installDir "shell\condabin\conda-hook.ps1"
#if (Test-Path $condaHook) {
# & $condaHook
# conda activate $installDir
#}

# Initialize conda for all supported shells on this machine
# (on Windows: PowerShell profile + cmd.exe autorun)
#& $condaExe init --all
#if ($LASTEXITCODE -ne 0) {
# throw "conda init --all failed with exit code $LASTEXITCODE"
#}
#Write-Host " [OK] conda init complete (restart your terminal to activate)"

Write-Host "`n=== Miniforge installation complete! ==="
15 changes: 0 additions & 15 deletions Core/Orchestration/README.md

This file was deleted.

15 changes: 7 additions & 8 deletions Core/Orchestration/install_all_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@

set -euo pipefail

REPO_BASE_URL="${REPO_BASE_URL:-https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/dev}"
export REPO_BASE_URL
PS_REPO_URL="${PS_REPO_URL:-https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main}"
export PS_REPO_URL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the export, are we sourcing other scripts? If this gets executed the env won't be shared to the caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not currently sourcing the scripts, instead running them in child shells, so the export is necessary. Sourcing them would be a bit dangerous because variables/functions etc. could overwrite each other if we are not very careful.


# Load the progress UI (defines the `progress` helper; the source guard in
# progress.sh skips its self-test when sourced rather than executed directly).
source <(curl -fsSL "$REPO_BASE_URL/Utils/progress.sh")
#source <(curl -fsSL "$PS_REPO_URL/Utils/progress.sh")

echo "========================================="
echo " DTU Python Support - Full Installation"
echo "========================================="
echo ""

# Step 1: Install Miniforge/Conda
progress "Step 1/2: Miniforge" 10 \
bash <(curl -fsSL "$REPO_BASE_URL/Core/Conda/install/install_macOS.sh")
#progress "Step 1/2: Miniforge" 10 \
bash <(curl -fsSL "$PS_REPO_URL/Core/Conda/install/install_macOS.sh")

# Step 2: Install VS Code (includes extensions and settings)
progress "Step 2/2: VS Code" 5 \
bash <(curl -fsSL "$REPO_BASE_URL/Core/VsCode/install/install_macOS.sh")
#progress "Step 2/2: VS Code" 5 \
bash <(curl -fsSL "$PS_REPO_URL/Core/VsCode/install/install_macOS.sh")

echo "========================================="
echo " Installation complete!"
Expand Down
30 changes: 30 additions & 0 deletions Core/Orchestration/install_all_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# @doc
# @name: Full Installation (Windows)
# @description: Orchestrate the full installation of Miniforge and VS Code on Windows
# @category: Core
# @usage: irm https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main/Core/Orchestration/install_all_windows.ps1 | iex
# @requirements: Windows, PowerShell 5.1+
# @notes: Runs all installation steps in order: Miniforge, VS Code (with extensions and settings)
# @/doc

$ErrorActionPreference = "Stop"

if (-not $env:PS_REPO_URL) {
$env:PS_REPO_URL = "https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main"
}

Write-Host "========================================="
Write-Host " DTU Python Support - Full Installation"
Write-Host "========================================="
Write-Host ""

# Step 1: Install Miniforge/Conda
#Invoke-Expression (Invoke-WebRequest -Uri "$env:PS_REPO_URL/Core/Conda/install/install_windows.ps1" -UseBasicParsing).Content

# Step 2: Install VS Code (includes extensions and settings)
Invoke-Expression (Invoke-WebRequest -Uri "$env:PS_REPO_URL/Core/VsCode/install/install_windows.ps1" -UseBasicParsing).Content

Write-Host "========================================="
Write-Host " Installation complete!"
Write-Host " Open Miniforge Prompt from the Start menu to interact with conda."
Write-Host "========================================="
8 changes: 4 additions & 4 deletions Core/Orchestration/uninstall_all_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

set -euo pipefail

REPO_BASE_URL="${REPO_BASE_URL:-https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/dev}"
export REPO_BASE_URL
PS_REPO_URL="${PS_REPO_URL:-https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main}"
export PS_REPO_URL

echo "========================================="
echo " DTU Python Support - Full Uninstall"
Expand All @@ -20,12 +20,12 @@ echo ""

# Step 1: Uninstall VS Code
echo "--- Step 1/2: VS Code ---"
bash <(curl -fsSL "$REPO_BASE_URL/Utils/VsCode/uninstall_macOS.sh")
bash <(curl -fsSL "$PS_REPO_URL/Utils/VsCode/uninstall_macOS.sh")
echo ""

# Step 2: Uninstall Conda
echo "--- Step 2/2: Conda ---"
bash <(curl -fsSL "$REPO_BASE_URL/Utils/Conda/uninstall_macOS.sh")
bash <(curl -fsSL "$PS_REPO_URL/Utils/Conda/uninstall_macOS.sh")
echo ""

echo "========================================="
Expand Down
31 changes: 31 additions & 0 deletions Core/Orchestration/uninstall_all_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @doc
# @name: Full Uninstall (Windows)
# @description: Uninstall VS Code and all detected Conda distributions on Windows
# @category: Core
# @usage: irm https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main/Core/Orchestration/uninstall_all_windows.ps1 | iex
# @requirements: Windows, PowerShell 5.1+
# @notes: Removes VS Code first, followed by per-user and machine-wide Conda distributions and current-user data.
# @/doc

$ErrorActionPreference = "Stop"

if (-not $env:PS_REPO_URL) {
$env:PS_REPO_URL = "https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main"
}

Write-Host "========================================="
Write-Host " DTU Python Support - Full Uninstall"
Write-Host "========================================="
Write-Host ""

Write-Host "--- Step 1/2: VS Code ---"
Invoke-Expression (Invoke-WebRequest -Uri "$env:PS_REPO_URL/Utils/VsCode/uninstall_Windows.ps1" -UseBasicParsing).Content
Write-Host ""

Write-Host "--- Step 2/2: Conda distributions ---"
Invoke-Expression (Invoke-WebRequest -Uri "$env:PS_REPO_URL/Utils/Conda/uninstall_Windows.ps1" -UseBasicParsing).Content
Write-Host ""

Write-Host "========================================="
Write-Host " Uninstall complete!"
Write-Host "========================================="
16 changes: 16 additions & 0 deletions Core/VsCode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Installs VS Code, applies default settings, and installs extensions.
curl -fsSL https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main/Core/VsCode/install/install_macOS.sh | bash
```

## Install (Windows)

The full Windows one-liner installs VS Code after Miniforge:

```powershell
irm https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/dev/Core/Orchestration/install_all_windows.ps1 | iex
```

For local integration tests, `PS_VSCODE_URL` can override the VS Code installer
download URL. Production installs leave it unset and select the x64 or ARM64
stable user installer automatically.

## Uninstall (macOS)

Removes VS Code, settings, extensions, and user data.
Expand All @@ -22,3 +34,7 @@ curl -fsSL https://raw.githubusercontent.com/dtudk/pythonsupport-scripts/main/Ut
- Disable chat agent
- Set Python locator to JS
- Disable telemetry

## Extensions

Listed and commented in `config/extensions.txt`.
18 changes: 12 additions & 6 deletions Core/VsCode/config/extensions_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@

set -euo pipefail

CODE_CLI="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
std_code_cli="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the code executable will only be available once one executes the Install code command in VSCode, will this path always be there? And is the directory always the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, there is a command on macos called mdfind which would allow us to find the VSC bundle on the system using the Spotlight machinery. Something like this might work:

code_app="$(mdfind "kMDItemCFBundleIdentifier == 'com.microsoft.VSCode'" | head -n 1)"
code_cli="$code_app/Contents/Resources/app/bin/code"

I can't really test this since I don't have a MacOS machine, but maybe this is something @philipnickel could look into.


echo "=== Installing VS Code Extensions ==="
echo ""

if [ ! -x "$CODE_CLI" ]; then
echo " ERROR: VS Code not found at $CODE_CLI"
exit 1
if [ ! -x "$std_code_cli" ]; then
code_cli=$(command -v code 2>/dev/null || true)

if [ ! -x "$code_cli" ]; then
echo " ERROR: VS Code not found at $std_code_cli"
exit 1
fi
else
code_cli="$std_code_cli"
fi

while IFS= read -r line || [ -n "$line" ]; do
[[ -z "$line" || "$line" == \#* ]] && continue

if "$CODE_CLI" --install-extension "$line" --force 2>/dev/null; then
if "$code_cli" --install-extension "$line" --force 2>/dev/null; then
echo " [OK] $line"
else
echo " [FAIL] $line"
fi
done < <(curl -fsSL "$REPO_BASE_URL/Core/VsCode/config/extensions.txt")
done < <(curl -fsSL "$PS_REPO_URL/Core/VsCode/config/extensions.txt")

echo ""
echo "=== Extensions complete! ==="
Loading