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

16
debian/postinst vendored
View File

@@ -42,11 +42,19 @@ case "$1" in
venv/bin/pip install --upgrade pip setuptools wheel
fi
# Install Python dependencies from pyproject.toml
# Install Python dependencies from requirements.txt
echo "Installing Python dependencies..."
venv/bin/pip install -e . || {
echo "Warning: pip install failed. You may need to install dependencies manually."
}
if [ -f "/opt/sensorpajen/requirements.txt" ]; then
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
PYTHON_PATH=$(readlink -f /opt/sensorpajen/venv/bin/python3)