-
Notifications
You must be signed in to change notification settings - Fork 8
zerothi comments #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
zerothi comments #153
Changes from all commits
e50d9d2
ab158c9
141ddc6
38a541e
c887e39
e038c85
aaef905
4160fbc
1c22cc3
ae007d0
56b23ad
9c311e8
c96e9dd
d41ea97
17dd92b
4032a8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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! ===" |
This file was deleted.
| 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 "=========================================" |
| 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 "=========================================" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently, there is a command on macos called 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! ===" | ||
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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
exportis necessary. Sourcing them would be a bit dangerous because variables/functions etc. could overwrite each other if we are not very careful.