From aeef9a424c7711fc7c121a4e542bcd4dc77d95c2 Mon Sep 17 00:00:00 2001 From: Fredrik Wahlberg Date: Sun, 28 Dec 2025 00:25:50 +0100 Subject: [PATCH] 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 --- debian/install | 1 + debian/postinst | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/debian/install b/debian/install index 3df76d3..1032039 100644 --- a/debian/install +++ b/debian/install @@ -1,6 +1,7 @@ src/sensorpajen/*.py opt/sensorpajen/src/sensorpajen/ scripts/approve-sensors.sh opt/sensorpajen/scripts/ pyproject.toml opt/sensorpajen/ +requirements.txt opt/sensorpajen/ readme.md usr/share/doc/sensorpajen/ INSTALL.md usr/share/doc/sensorpajen/ ROADMAP.md usr/share/doc/sensorpajen/ diff --git a/debian/postinst b/debian/postinst index bf90997..42c5b1c 100755 --- a/debian/postinst +++ b/debian/postinst @@ -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)