Repository navigation
Expand file tree
/
Copy pathsetup.bat
More file actions
157 lines (141 loc) · 5.48 KB
/
Copy pathsetup.bat
File metadata and controls
157 lines (141 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@echo off
setlocal
title Edge Scanner Setup
cd /d "%~dp0"
echo Edge Scanner setup
echo.
rem Python 3.11 to 3.14. A brand-new Python (3.15 in October 2026) has no Windows wheels yet for
rem some packages (pyarrow, pyyaml), so pip tries to compile them and fails. The py launcher can
rem pick a supported version when several are installed, whichever one is first on PATH.
set "VERSION_OK=import sys; sys.exit(0 if (3, 11) <= sys.version_info[:2] <= (3, 14) else 1)"
set "PY="
where py >nul 2>nul
if not errorlevel 1 (
for %%V in (3.13 3.12 3.14 3.11) do if not defined PY (
py -%%V -c "" >nul 2>nul && set "PY=py -%%V"
)
)
if not defined PY (
where python >nul 2>nul
if not errorlevel 1 (
python -c "%VERSION_OK%" && set "PY=python"
)
)
if defined PY goto :python_found
rem None found: offer to install 3.13 for this Windows user. winget ships with Windows 10 and 11.
where winget >nul 2>nul
if errorlevel 1 goto :python_missing
echo No Python 3.11 to 3.14 was found. Setup can install Python 3.13 for you, for this Windows
echo user only. A newer Python already on this machine stays as it is.
choice /C YN /M "Install Python 3.13 now"
if errorlevel 2 goto :python_missing
rem InstallLauncherAllUsers=0 keeps the py launcher per-user too, so no admin prompt is needed.
winget install --exact --id Python.Python.3.13 --scope user --silent --accept-package-agreements --accept-source-agreements --custom "InstallLauncherAllUsers=0"
rem PATH in this window is not refreshed, so use the installed python.exe by its path.
set "PY313=%LOCALAPPDATA%\Programs\Python\Python313\python.exe"
if exist "%PY313%" set PY="%PY313%"
if defined PY goto :python_found
:python_missing
echo Python 3.11 to 3.14 is needed. Python 3.13 is recommended:
echo https://www.python.org/downloads/windows/
echo Tick "Add python.exe to PATH" in the installer, then run setup.bat again.
echo A newer Python can stay installed; setup picks 3.13 when both are there.
where python >nul 2>nul && (
echo This machine has:
python --version
)
goto :fail
:python_found
echo Using:
%PY% --version
rem Node.js 20.19+, 22.13+ or 24+: the dashboard's build tools (Vite 8, ESLint 10) need it, and an
rem older Node fails at step 4 with an engine or syntax error.
set "NODE_OK=const [a,b]=process.versions.node.split('.').map(Number);process.exit((a===20&&b>=19)||(a===22&&b>=13)||a>=24?0:1)"
where node >nul 2>nul && call node -e "%NODE_OK%" >nul 2>nul && goto :node_found
rem Missing or too old: offer the current LTS. winget ships with Windows 10 and 11.
where winget >nul 2>nul
if errorlevel 1 goto :node_missing
echo Node.js 20.19 or newer is needed to build the dashboard.
where node >nul 2>nul && (
echo This machine has:
call node --version
)
echo Setup can install the current Node.js LTS for you. Windows will ask for permission.
choice /C YN /M "Install Node.js LTS now"
if errorlevel 2 goto :node_missing
winget install --exact --id OpenJS.NodeJS.LTS --silent --accept-package-agreements --accept-source-agreements
rem PATH in this window is not refreshed, so put the new install first.
set "PATH=%ProgramFiles%\nodejs;%PATH%"
call node -e "%NODE_OK%" >nul 2>nul && goto :node_found
:node_missing
echo Node.js 20.19 or newer is needed. The LTS version is recommended: https://nodejs.org/
echo Install it, then run setup.bat again.
where node >nul 2>nul && (
echo This machine has:
call node --version
)
goto :fail
:node_found
where npm >nul 2>nul
if errorlevel 1 (
echo npm was not found next to Node.js. Reinstall the LTS version from https://nodejs.org/
goto :fail
)
echo [1/5] Creating the Python environment in .venv
if exist ".venv\Scripts\python.exe" (
rem A .venv left by an earlier run on an unsupported Python is rebuilt.
".venv\Scripts\python.exe" -c "%VERSION_OK%" >nul 2>nul
if errorlevel 1 (
echo Rebuilding .venv, it was made with an unsupported Python
rmdir /s /q .venv
)
)
if not exist ".venv\Scripts\python.exe" (
%PY% -m venv .venv
if errorlevel 1 goto :fail
)
echo [2/5] Installing the Python packages
".venv\Scripts\python.exe" -m pip install --quiet --upgrade pip
".venv\Scripts\python.exe" -m pip install --quiet -r requirements.txt
if errorlevel 1 goto :fail
echo [3/5] Installing the dashboard packages (a few minutes the first time)
pushd dashboard-v2
call npm ci --no-audit --no-fund --loglevel=error
if errorlevel 1 (
rem An older npm can reject a lock file written by a newer one; npm install reconciles it.
echo Retrying with npm install
call npm install --no-audit --no-fund --loglevel=error
if errorlevel 1 (
popd
goto :fail
)
)
echo [4/5] Building the dashboard
call npm run build
if errorlevel 1 (
popd
goto :fail
)
popd
echo [5/5] Creating .env for your market-data keys
if exist ".env" (
echo .env already exists, left as it is
) else (
copy ".env.example" ".env" >nul
echo Created. Open .env and add your Alpaca keys, or set DATA_PROVIDER=schwab.
)
echo.
echo Setup finished. Add your keys to .env, then start it with start_scanner.bat
echo and open http://localhost:7777
echo.
echo Every install starts empty: no watchlists, no saved screens of your own and no alert
echo history. The first start downloads market history and can take 10 to 20 minutes.
echo Optional sample setups: .venv\Scripts\python scripts\install_setup_library.py
echo.
pause
exit /b 0
:fail
echo.
echo Setup stopped. Fix the problem above and run setup.bat again; finished steps are skipped or repeated safely.
pause
exit /b 1