Skip to content

[enh/venv]: feat(install): introduce venv-based runtime setup with proper permissions#153

Open
KoenigMjr wants to merge 3 commits intoBOSWatch:developfrom
KoenigMjr:enh/venv
Open

[enh/venv]: feat(install): introduce venv-based runtime setup with proper permissions#153
KoenigMjr wants to merge 3 commits intoBOSWatch:developfrom
KoenigMjr:enh/venv

Conversation

@KoenigMjr
Copy link
Contributor

🇩🇪 DE

Ersetzt die implizite Abhängigkeit von systemweiten Python-Paketen durch eine dedizierte virtuelle Umgebung und explizites Laufzeitabhängigkeitsmanagement.

Änderungen:

  • Erstellen einer projektlokalen Python-Umgebung während der Installation
  • Installieren von Laufzeitabhängigkeiten explizit über requirements-runtime.txt
  • Beheben von ModuleNotFoundError-Problemen in isolierten Umgebungen (z. B. requests)
  • Erkennen des tatsächlichen Benutzers bei Ausführung mit sudo (SUDO_USER)
  • Zuweisen der korrekten Besitzrechte für das BOSWatch-Verzeichnis bei Verwendung der virtuellen Umgebung
  • Anwenden von setgid (2775) auf das Log-Verzeichnis, sodass mit sudo erstellte Dateien vom Benutzer verwaltet werden können
  • Festlegen expliziter Berechtigungen für Python-Skripte und Konfigurationsdateien

Dies gewährleistet eine reproduzierbare, systemunabhängige Installation und verhindert Berechtigungsprobleme während der Laufzeit und bei der Log-Erstellung

Caution

BEKANNTE EINSCHRÄNKUNGEN
Durch die vollständige Installation von allen benötigten Dependencies ist die Installation nun natürlich a) bisschen langsamer und b) größer.

OOTB ist das gesamte Programm nun 177MB schwer, alleine die mysql-Lib ist ca. 60MB groß.

IMHO ist das derzeit vertretbar - sollten mehrere Module/Plugins noch dazukommen, muss umgedacht werden. Zum Vorteil des Userkomfort habe ich mich, abweichend von der derzeitigen Strategie, dafür entschieden.

z.B. es später mal ein Tool gibt, was die Installation, Update, Service-Installation und Library-(Nach-)Installation aufgrund der Config übernimmt (Check).

Können gerne darüber diskutieren!
Und bitte, wie immer, meinen Code-Änderungen kritisch prüfen!


🇬🇧 EN

Replace the implicit dependency on system-wide Python packages with a
dedicated virtual environment and explicit runtime dependency management.

Changes:

  • Create a project-local Python venv during installation
  • Install runtime dependencies explicitly via requirements-runtime.txt
  • Fix ModuleNotFoundError issues in isolated environments (e.g. requests)
  • Detect the actual user when running via sudo (SUDO_USER)
  • Assign correct ownership to the BOSWatch directory for venv usage
  • Apply setgid (2775) to the log directory so files created with sudo
    remain manageable by the user
  • Set explicit permissions for Python scripts and config files

This ensures a reproducible, system-independent installation and prevents
permission issues during runtime and log creation.

Caution

KNOWN LIMITATIONS:
Due to the complete installation of all required dependencies, the installation is now naturally a) a bit slower and b) larger.

Out of the box, the entire program is now 177MB, with the MySQL library alone being approximately 60MB.

IMHO, this is currently acceptable – if more modules/plugins are added, a rethink will be necessary. For the sake of user comfort, I decided to deviate from the usual strategy.

E.g.: a tool would be available later that handles installation, updates, service installation, and library (post-)installation based on the configuration (Check)

You are welcomed to discuss!
And please, as always, critically examine my code changes!


#144 , #146 , #147 , #148 sollten damit erledigt sein / should be done.

…oper permissions

Replace the implicit dependency on system-wide Python packages with a
dedicated virtual environment and explicit runtime dependency management.

Changes:
- Create a project-local Python venv during installation
- Install runtime dependencies explicitly via requirements-runtime.txt
- Fix ModuleNotFoundError issues in isolated environments (e.g. requests)
- Detect the actual user when running via sudo (SUDO_USER)
- Assign correct ownership to the BOSWatch directory for venv usage
- Apply setgid (2775) to the log directory so files created with sudo
  remain manageable by the user
- Set explicit permissions for Python scripts and config files

This ensures a reproducible, system-independent installation and prevents
permission issues during runtime and log creation.
including Colorama into requirements-runtime.txt due to minimum required space (~50–100 KB)
removing colorama-installation in install_service.py (obsolete)
@KoenigMjr
Copy link
Contributor Author

ah ja, vergessen....
Getestet auf: Raspberry Pi 3B+ mit aktuellem Raspberry Pi OS Trixie (Debian 13).
Der Pi wurde vorher neu aufgesetzt per Imager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant