techfreakworm commited on
Commit
79f58fb
·
unverified ·
1 Parent(s): 8fc86e0

feat(scripts): start.ps1 offers winget install of Python 3.11 + Node LTS; start.sh hints brew/apt

Browse files
Files changed (3) hide show
  1. README.md +9 -0
  2. scripts/start.ps1 +60 -6
  3. scripts/start.sh +14 -1
README.md CHANGED
@@ -11,10 +11,19 @@ ZeroGPU-decorator-ready).
11
 
12
  ./scripts/start.sh
13
 
 
 
 
 
14
  ### Windows
15
 
16
  scripts\start.bat
17
 
 
 
 
 
 
18
  The script creates a venv, installs Python and Node deps, builds the SPA,
19
  and opens the studio at http://127.0.0.1:7860.
20
 
 
11
 
12
  ./scripts/start.sh
13
 
14
+ Prereqs: Python 3.11+ and Node.js 20+. If missing, the script will tell you
15
+ the one-line install command for your platform (`brew install python@3.11`
16
+ on macOS, `apt install python3.11 python3.11-venv` on Debian/Ubuntu).
17
+
18
  ### Windows
19
 
20
  scripts\start.bat
21
 
22
+ If Python 3.11 or Node.js LTS isn't installed, the script will detect that
23
+ and offer to install them via `winget` (built into Windows 10 1809+ and
24
+ Windows 11). Accept the prompt and re-run `scripts\start.bat` after install
25
+ finishes so the new PATH takes effect.
26
+
27
  The script creates a venv, installs Python and Node deps, builds the SPA,
28
  and opens the studio at http://127.0.0.1:7860.
29
 
scripts/start.ps1 CHANGED
@@ -7,19 +7,65 @@ $ErrorActionPreference = "Stop"
7
  $Root = Resolve-Path "$PSScriptRoot/.."
8
  Set-Location $Root
9
 
10
- $python = Get-Command py -ErrorAction SilentlyContinue
11
- if (-not $python) {
12
- Write-Error "Python launcher 'py' not found. Install Python 3.11+ from python.org."
13
- exit 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
 
 
 
 
 
 
 
16
  if (-not (Test-Path ".venv")) {
17
  Write-Host "==> Creating venv (.venv)"
18
  & py -3.11 -m venv .venv
19
  }
20
 
21
- $activate = ".venv/Scripts/Activate.ps1"
22
- . $activate
23
 
24
  $reqHash = (Get-FileHash requirements.txt -Algorithm SHA1).Hash
25
  $marker = ".venv/.installed-marker"
@@ -30,6 +76,10 @@ if (-not (Test-Path $marker) -or (Get-Content $marker) -ne $reqHash) {
30
  Set-Content $marker $reqHash
31
  }
32
 
 
 
 
 
33
  if (-not (Test-Path "web/node_modules")) {
34
  Write-Host "==> Installing web deps"
35
  Push-Location web
@@ -47,6 +97,10 @@ if (-not (Test-Path "server/static/index.html")) {
47
  Copy-Item -Recurse "web/dist/*" "server/static/"
48
  }
49
 
 
 
 
 
50
  $env:PYTORCH_ENABLE_MPS_FALLBACK = "1"
51
  $Url = "http://${BindHost}:$Port"
52
  Write-Host "==> Serving on $Url"
 
7
  $Root = Resolve-Path "$PSScriptRoot/.."
8
  Set-Location $Root
9
 
10
+ # ---------------------------------------------------------------------------
11
+ # Prereq check + optional winget install
12
+ # ---------------------------------------------------------------------------
13
+
14
+ function Test-Py311 {
15
+ $py = Get-Command py -ErrorAction SilentlyContinue
16
+ if (-not $py) { return $false }
17
+ $listing = (& py -0 2>&1 | Out-String)
18
+ return ($listing -match "3\.11")
19
+ }
20
+
21
+ function Test-Node {
22
+ return [bool] (Get-Command npm -ErrorAction SilentlyContinue)
23
+ }
24
+
25
+ function Install-WithWinget($name, $id) {
26
+ $w = Get-Command winget -ErrorAction SilentlyContinue
27
+ if (-not $w) {
28
+ Write-Host ""
29
+ Write-Host "$name not found, and 'winget' is not available on this system."
30
+ Write-Host "Install $name manually, then re-run scripts\start.bat."
31
+ if ($name -eq "Python 3.11") {
32
+ Write-Host " -> https://www.python.org/downloads/"
33
+ } elseif ($name -eq "Node.js LTS") {
34
+ Write-Host " -> https://nodejs.org/"
35
+ }
36
+ exit 1
37
+ }
38
+ Write-Host ""
39
+ $resp = Read-Host "$name not found. Install now via winget ($id)? [Y/n]"
40
+ if ($resp -and ($resp -ne "y") -and ($resp -ne "Y")) {
41
+ Write-Host "Skipped. Install $name manually and re-run."
42
+ exit 1
43
+ }
44
+ Write-Host "==> Installing $name (this can take a couple of minutes)…"
45
+ & winget install --id $id -e --silent --accept-package-agreements --accept-source-agreements
46
+ if ($LASTEXITCODE -ne 0) {
47
+ Write-Error "winget install failed (exit $LASTEXITCODE)."
48
+ exit 1
49
+ }
50
+ Write-Host ""
51
+ Write-Host "==> $name installed."
52
+ Write-Host " Close this window and run scripts\start.bat again so the new PATH takes effect."
53
+ exit 0
54
  }
55
 
56
+ if (-not (Test-Py311)) { Install-WithWinget "Python 3.11" "Python.Python.3.11" }
57
+ if (-not (Test-Node)) { Install-WithWinget "Node.js LTS" "OpenJS.NodeJS.LTS" }
58
+
59
+ # ---------------------------------------------------------------------------
60
+ # venv + Python deps
61
+ # ---------------------------------------------------------------------------
62
+
63
  if (-not (Test-Path ".venv")) {
64
  Write-Host "==> Creating venv (.venv)"
65
  & py -3.11 -m venv .venv
66
  }
67
 
68
+ . .venv/Scripts/Activate.ps1
 
69
 
70
  $reqHash = (Get-FileHash requirements.txt -Algorithm SHA1).Hash
71
  $marker = ".venv/.installed-marker"
 
76
  Set-Content $marker $reqHash
77
  }
78
 
79
+ # ---------------------------------------------------------------------------
80
+ # web deps + build
81
+ # ---------------------------------------------------------------------------
82
+
83
  if (-not (Test-Path "web/node_modules")) {
84
  Write-Host "==> Installing web deps"
85
  Push-Location web
 
97
  Copy-Item -Recurse "web/dist/*" "server/static/"
98
  }
99
 
100
+ # ---------------------------------------------------------------------------
101
+ # serve
102
+ # ---------------------------------------------------------------------------
103
+
104
  $env:PYTORCH_ENABLE_MPS_FALLBACK = "1"
105
  $Url = "http://${BindHost}:$Port"
106
  Write-Host "==> Serving on $Url"
scripts/start.sh CHANGED
@@ -10,7 +10,20 @@ if command -v python3.11 >/dev/null 2>&1; then
10
  elif command -v python3 >/dev/null 2>&1; then
11
  PY=python3
12
  else
13
- echo "ERROR: python3.11 (or python3) not found. Install Python 3.11+." >&2
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  exit 1
15
  fi
16
 
 
10
  elif command -v python3 >/dev/null 2>&1; then
11
  PY=python3
12
  else
13
+ echo "ERROR: python3.11 (or python3) not found." >&2
14
+ case "$(uname -s)" in
15
+ Darwin) echo " Install with: brew install python@3.11" >&2 ;;
16
+ Linux) echo " Install with your package manager, e.g.: sudo apt install python3.11 python3.11-venv" >&2 ;;
17
+ esac
18
+ exit 1
19
+ fi
20
+
21
+ if ! command -v npm >/dev/null 2>&1; then
22
+ echo "ERROR: npm not found." >&2
23
+ case "$(uname -s)" in
24
+ Darwin) echo " Install with: brew install node" >&2 ;;
25
+ Linux) echo " Install with your package manager, e.g.: sudo apt install nodejs npm" >&2 ;;
26
+ esac
27
  exit 1
28
  fi
29