Fix Python dependencies installation in postinst

- Add requirements.txt to debian/install
- Update postinst to use requirements.txt for pip install
- Install from requirements.txt instead of -e . (editable install)
- Ensures bluepy and paho-mqtt are installed in venv
- Fixes 'ModuleNotFoundError: No module named bluetooth' on startup
This commit is contained in:
2025-12-28 00:25:50 +01:00
parent 36e91c7246
commit aeef9a424c
2 changed files with 13 additions and 4 deletions

1
debian/install vendored
View File

@@ -1,6 +1,7 @@
src/sensorpajen/*.py opt/sensorpajen/src/sensorpajen/ src/sensorpajen/*.py opt/sensorpajen/src/sensorpajen/
scripts/approve-sensors.sh opt/sensorpajen/scripts/ scripts/approve-sensors.sh opt/sensorpajen/scripts/
pyproject.toml opt/sensorpajen/ pyproject.toml opt/sensorpajen/
requirements.txt opt/sensorpajen/
readme.md usr/share/doc/sensorpajen/ readme.md usr/share/doc/sensorpajen/
INSTALL.md usr/share/doc/sensorpajen/ INSTALL.md usr/share/doc/sensorpajen/
ROADMAP.md usr/share/doc/sensorpajen/ ROADMAP.md usr/share/doc/sensorpajen/

16
debian/postinst vendored
View File

@@ -42,11 +42,19 @@ case "$1" in
venv/bin/pip install --upgrade pip setuptools wheel venv/bin/pip install --upgrade pip setuptools wheel
fi fi
# Install Python dependencies from pyproject.toml # Install Python dependencies from requirements.txt
echo "Installing Python dependencies..." echo "Installing Python dependencies..."
venv/bin/pip install -e . || { if [ -f "/opt/sensorpajen/requirements.txt" ]; then
echo "Warning: pip install failed. You may need to install dependencies manually." venv/bin/pip install -r /opt/sensorpajen/requirements.txt
} else
echo "Warning: requirements.txt not found, installing bluepy and paho-mqtt directly"
venv/bin/pip install bluepy paho-mqtt
fi
if [ $? -ne 0 ]; then
echo "Error: Failed to install dependencies"
exit 1
fi
# Set Bluetooth capabilities on Python executable # Set Bluetooth capabilities on Python executable
PYTHON_PATH=$(readlink -f /opt/sensorpajen/venv/bin/python3) PYTHON_PATH=$(readlink -f /opt/sensorpajen/venv/bin/python3)