From 81640d7205122b67eeef700d76f5003fa7cb02d4 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 6 Jul 2025 20:20:11 -0400 Subject: [PATCH] feat(installer): auto-install python on Windows --- README.md | 3 ++- scripts/install.ps1 | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 587381a..4400cad 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,8 @@ bash -c "$(curl -sSL https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/ ```powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $scriptContent = (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.ps1'); & ([scriptblock]::create($scriptContent)) ``` -The Windows installer will attempt to install Git automatically if it is not already available. +The Windows installer will attempt to install Git automatically if it is not already available. It also tries to +install Python 3 using `winget`, `choco`, or `scoop` when Python is missing. **Note:** If you are using Python 3.13 or newer, install the [Microsoft Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and reopen PowerShell before rerunning the installer. *Install the beta branch:* ```powershell diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 2971632..1d743ee 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -85,7 +85,25 @@ if (-not (Get-Command git -ErrorAction SilentlyContinue)) { } } $pythonExe = Get-Command python -ErrorAction SilentlyContinue -if (-not $pythonExe) { Write-Error "Python 3 is not installed or not in your PATH. Please install it from https://www.python.org/" } +if (-not $pythonExe) { + Write-Warning "Python 3 is not installed. Attempting to install..." + if (Get-Command winget -ErrorAction SilentlyContinue) { + try { winget install --id Python.Python.3 -e --source winget -h } catch { Write-Warning "Failed to install Python via winget." } + } elseif (Get-Command choco -ErrorAction SilentlyContinue) { + try { choco install python -y } catch { Write-Warning "Failed to install Python via Chocolatey." } + } elseif (Get-Command scoop -ErrorAction SilentlyContinue) { + try { scoop install python } catch { Write-Warning "Failed to install Python via Scoop." } + } else { + Write-Error "Python 3 is not installed. Please install it from https://www.python.org/ and ensure it's in your PATH." + } + if (-not (Get-Command python -ErrorAction SilentlyContinue)) { + $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + + [System.Environment]::GetEnvironmentVariable('Path','User') + if (-not (Get-Command python -ErrorAction SilentlyContinue)) { + Write-Error "Python installation succeeded but python not found in PATH. Please open a new terminal or add Python to PATH manually." + } + } +} # Warn about unsupported Python versions $pyVersionString = (& python --version) -replace '[^0-9\.]', ''