Skip to content

Commit 9fbbcf6

Browse files
feat: enhance installation scripts with pre-flight checks, Python version validation, and robust pipx command handling
1 parent 50dfaff commit 9fbbcf6

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

scripts/install_macos.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if [[ ! -d "$FL_HARDWARE" ]]; then
1717
echo " Open FL Studio at least once, then re-run this script."
1818
exit 1
1919
fi
20+
if [[ ! -f "$REPO_ROOT/fl_controller/FLStudioPilot/device_FLStudioPilot.py" ]]; then
21+
echo " Error: Source controller script not found. Are you running this from the cloned repo?"
22+
exit 1
23+
fi
2024
mkdir -p "$TARGET"
2125
cp "$REPO_ROOT/fl_controller/FLStudioPilot/device_FLStudioPilot.py" "$TARGET/"
2226
echo " Installed to $TARGET"
@@ -47,8 +51,13 @@ if ! command -v python3 >/dev/null 2>&1; then
4751
echo " python3 not found. Install Python 3.10+ and re-run."
4852
exit 1
4953
fi
54+
if ! python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)' 2>/dev/null; then
55+
echo " Python 3.10+ is required. Please upgrade your Python installation."
56+
exit 1
57+
fi
5058
cd "$REPO_ROOT"
5159

60+
PIPX_CMD="pipx"
5261
if [[ "$USE_PIPX" -eq 1 ]]; then
5362
if ! command -v pipx >/dev/null 2>&1; then
5463
if [[ "$INSTALL_PIPX" -eq 1 ]]; then
@@ -57,13 +66,14 @@ if [[ "$USE_PIPX" -eq 1 ]]; then
5766
python3 -m pipx ensurepath
5867
echo " WARNING: PATH changes may require restarting your terminal!"
5968
export PATH="$HOME/.local/bin:$PATH"
69+
PIPX_CMD="python3 -m pipx"
6070
else
6171
echo " pipx not found. Install pipx manually or run this script with --install-pipx."
6272
exit 1
6373
fi
6474
fi
6575
echo " Installing via pipx (editable)..."
66-
pipx install --force --editable .
76+
$PIPX_CMD install --force --editable .
6777
else
6878
if [[ -z "${VIRTUAL_ENV:-}" ]]; then
6979
if [[ ! -d ".venv" ]]; then
@@ -87,7 +97,8 @@ fi
8797

8898
echo
8999
echo "[4/4] Checking for IAC Driver ports..."
90-
python3 - <<'PYEOF'
100+
if python3 -c 'import mido' 2>/dev/null; then
101+
python3 - <<'PYEOF'
91102
import mido
92103
names = set(mido.get_output_names()) | set(mido.get_input_names())
93104
rx, tx = "FLStudioPilot RX", "FLStudioPilot TX"
@@ -97,6 +108,10 @@ if not missing:
97108
else:
98109
print(f" Missing ports: {missing}")
99110
PYEOF
111+
else
112+
echo " (Automated port check skipped: 'mido' module not in global environment.)"
113+
echo " If using pipx, please manually ensure you have created the required IAC ports."
114+
fi
100115

101116
if [[ "$USE_PIPX" -eq 1 ]]; then
102117
CMD_DAEMON="fls-pilot-daemon"

scripts/install_windows.bat

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,33 @@ if not exist "%FL_SETTINGS%\Hardware" (
3636
echo Open FL Studio at least once, then re-run this script.
3737
exit /b 1
3838
)
39+
if not exist "%REPO_ROOT%\fl_controller\FLStudioPilot\device_FLStudioPilot.py" (
40+
echo Error: Source controller script not found. Are you running this from the cloned repo?
41+
exit /b 1
42+
)
3943
if not exist "%HW_TARGET%" mkdir "%HW_TARGET%"
44+
if errorlevel 1 ( echo Failed to create target directory. ^("%HW_TARGET%"^) & exit /b 1 )
4045
copy /Y "%REPO_ROOT%\fl_controller\FLStudioPilot\device_FLStudioPilot.py" "%HW_TARGET%\" >nul
4146
if errorlevel 1 ( echo Copy failed. Aborting. & exit /b 1 )
4247
echo Installed to %HW_TARGET%
4348

4449
echo.
4550
echo [2/4] Installing the MCP server...
4651
where python >nul 2>nul
47-
if errorlevel 1 ( echo Python not found on PATH. Install Python 3.12+ and re-run. & exit /b 1 )
52+
if errorlevel 1 ( echo Python not found on PATH. Install Python 3.10+ and re-run. & exit /b 1 )
53+
python -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>nul
54+
if errorlevel 1 ( echo Python 3.10+ is required. Please upgrade your Python installation. & exit /b 1 )
4855
pushd "%REPO_ROOT%"
4956

57+
set "PIPX_CMD=pipx"
5058
if "!USE_PIPX!"=="1" (
5159
where pipx >nul 2>nul
5260
if errorlevel 1 (
5361
if "!INSTALL_PIPX!"=="1" (
5462
echo pipx not found. Attempting to install via pip...
5563
python -m pip install --user pipx
5664
python -m pipx ensurepath
65+
set "PIPX_CMD=python -m pipx"
5766
echo WARNING: PATH changes may require restarting the terminal!
5867
) else (
5968
echo pipx not found. Install pipx manually or run this script with --install-pipx.
@@ -62,11 +71,12 @@ if "!USE_PIPX!"=="1" (
6271
)
6372
)
6473
echo Installing via pipx (editable)...
65-
pipx install --force --editable .
74+
!PIPX_CMD! install --force --editable .
6675
) else (
6776
if not exist ".venv" (
6877
echo Creating virtual environment ^(.venv^)...
6978
python -m venv .venv
79+
if errorlevel 1 ( echo Failed to create virtual environment. & popd & exit /b 1 )
7080
)
7181
echo Installing via .venv...
7282
.venv\Scripts\python.exe -m pip install --upgrade pip >nul
@@ -87,7 +97,13 @@ if errorlevel 1 echo Note: could not pre-seed MCP_Apply (FL Piano roll scripts
8797

8898
echo.
8999
echo [4/4] Checking loopMIDI ports...
90-
python -c "import mido; names=set(mido.get_output_names())|set(mido.get_input_names()); req=('FLStudioPilot RX','FLStudioPilot TX'); missing=[n for n in req if not any(n.lower() in x.lower() for x in names)]; print(' All required ports present.') if not missing else print(' MISSING ports: %s -- create them in loopMIDI.' % missing)"
100+
python -c "import mido" 2>nul
101+
if errorlevel 1 (
102+
echo ^(Automated port check skipped: 'mido' module not in global environment.^)
103+
echo If using pipx, please manually ensure you have created the required loopMIDI ports.
104+
) else (
105+
python -c "import mido; names=set(mido.get_output_names())|set(mido.get_input_names()); req=('FLStudioPilot RX','FLStudioPilot TX'); missing=[n for n in req if not any(n.lower() in x.lower() for x in names)]; print(' All required ports present.') if not missing else print(' MISSING ports: %s -- create them in loopMIDI.' % missing)"
106+
)
91107

92108
echo.
93109
echo ============================================================================

0 commit comments

Comments
 (0)