From d5f3c0f7aca2af1f0c72b6f322d3cb5f9885c255 Mon Sep 17 00:00:00 2001 From: rpotter6298 Date: Sun, 30 Aug 2026 15:05:15 +0200 Subject: [PATCH] Flatten to a single package directory The checkout is now astrape/astrape-ems, not astrape/astrape-ems/. The package contents move to the repository root and pyproject maps the package name to '.' via package-dir, with the subpackages listed explicitly. The systemd units move out to /srv/astrape/deploy/systemd, outside every repository, because they describe this deployment rather than any one component. Verified both install modes: editable, which is how the deployment runs, and a plain wheel install, which is what the container build does. Co-Authored-By: Claude Opus 5 (1M context) --- astrape_ems/__init__.py => __init__.py | 0 {astrape_ems/classes => classes}/__init__.py | 0 {astrape_ems/classes => classes}/client.py | 0 {astrape_ems/classes => classes}/env.py | 0 {astrape_ems/classes => classes}/modbus.py | 0 {astrape_ems/classes => classes}/registers.py | 0 {astrape_ems/classes => classes}/store.py | 0 deploy/systemd/astrape-sigen.service | 25 ------------------- pyproject.toml | 8 ++++-- {astrape_ems/scripts => scripts}/__init__.py | 0 .../scripts => scripts}/daemons/__init__.py | 0 .../daemons/plant_daemon.py | 0 .../scripts => scripts}/debug/__init__.py | 0 .../scripts => scripts}/debug/debug_plant.py | 0 .../scripts => scripts}/debug/modbus_test.py | 0 15 files changed, 6 insertions(+), 27 deletions(-) rename astrape_ems/__init__.py => __init__.py (100%) rename {astrape_ems/classes => classes}/__init__.py (100%) rename {astrape_ems/classes => classes}/client.py (100%) rename {astrape_ems/classes => classes}/env.py (100%) rename {astrape_ems/classes => classes}/modbus.py (100%) rename {astrape_ems/classes => classes}/registers.py (100%) rename {astrape_ems/classes => classes}/store.py (100%) delete mode 100644 deploy/systemd/astrape-sigen.service rename {astrape_ems/scripts => scripts}/__init__.py (100%) rename {astrape_ems/scripts => scripts}/daemons/__init__.py (100%) rename {astrape_ems/scripts => scripts}/daemons/plant_daemon.py (100%) rename {astrape_ems/scripts => scripts}/debug/__init__.py (100%) rename {astrape_ems/scripts => scripts}/debug/debug_plant.py (100%) rename {astrape_ems/scripts => scripts}/debug/modbus_test.py (100%) diff --git a/astrape_ems/__init__.py b/__init__.py similarity index 100% rename from astrape_ems/__init__.py rename to __init__.py diff --git a/astrape_ems/classes/__init__.py b/classes/__init__.py similarity index 100% rename from astrape_ems/classes/__init__.py rename to classes/__init__.py diff --git a/astrape_ems/classes/client.py b/classes/client.py similarity index 100% rename from astrape_ems/classes/client.py rename to classes/client.py diff --git a/astrape_ems/classes/env.py b/classes/env.py similarity index 100% rename from astrape_ems/classes/env.py rename to classes/env.py diff --git a/astrape_ems/classes/modbus.py b/classes/modbus.py similarity index 100% rename from astrape_ems/classes/modbus.py rename to classes/modbus.py diff --git a/astrape_ems/classes/registers.py b/classes/registers.py similarity index 100% rename from astrape_ems/classes/registers.py rename to classes/registers.py diff --git a/astrape_ems/classes/store.py b/classes/store.py similarity index 100% rename from astrape_ems/classes/store.py rename to classes/store.py diff --git a/deploy/systemd/astrape-sigen.service b/deploy/systemd/astrape-sigen.service deleted file mode 100644 index b03552e..0000000 --- a/deploy/systemd/astrape-sigen.service +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=Astrape Sigenergy Plant Ingest -After=network-online.target -Wants=network-online.target - -[Service] -Type=simple -User=gibil -Group=gibil -WorkingDirectory=/srv/astrape -Environment=PYTHONUNBUFFERED=1 -Environment=PYTHONDONTWRITEBYTECODE=1 -# WorkingDirectory is /srv/astrape, which also holds the gibil checkout. Without -# this, Python prepends the working directory to sys.path and the repo root -# /srv/astrape/gibil shadows the installed package as a namespace portion -- -# gibil.__file__ becomes None and imports work only by accident. All code is -# installed into the venv, so nothing needs the working directory on sys.path. -Environment=PYTHONSAFEPATH=1 - -ExecStart=/srv/astrape/.venv/bin/python -m astrape_ems.scripts.daemons.plant_daemon -Restart=always -RestartSec=10 - -[Install] -WantedBy=multi-user.target diff --git a/pyproject.toml b/pyproject.toml index b9bf88b..e66acf9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,5 +9,9 @@ description = "Energy backend connection: Sigenergy Modbus client and plant stor requires-python = ">=3.12" dependencies = ["gibil", "psycopg[binary]>=3.2,<4", "pymodbus>=3.8,<4"] -[tool.setuptools.packages.find] -include = ["astrape_ems*"] +# Flat layout: this repository *is* the package. package-dir maps astrape_ems to the +# repository root rather than to a nested astrape_ems/ directory, so the checkout is +# astrape/astrape-ems and not astrape/astrape-ems/astrape_ems. +[tool.setuptools] +packages = ["astrape_ems", "astrape_ems.classes", "astrape_ems.scripts", "astrape_ems.scripts.daemons", "astrape_ems.scripts.debug"] +package-dir = {"astrape_ems" = "."} diff --git a/astrape_ems/scripts/__init__.py b/scripts/__init__.py similarity index 100% rename from astrape_ems/scripts/__init__.py rename to scripts/__init__.py diff --git a/astrape_ems/scripts/daemons/__init__.py b/scripts/daemons/__init__.py similarity index 100% rename from astrape_ems/scripts/daemons/__init__.py rename to scripts/daemons/__init__.py diff --git a/astrape_ems/scripts/daemons/plant_daemon.py b/scripts/daemons/plant_daemon.py similarity index 100% rename from astrape_ems/scripts/daemons/plant_daemon.py rename to scripts/daemons/plant_daemon.py diff --git a/astrape_ems/scripts/debug/__init__.py b/scripts/debug/__init__.py similarity index 100% rename from astrape_ems/scripts/debug/__init__.py rename to scripts/debug/__init__.py diff --git a/astrape_ems/scripts/debug/debug_plant.py b/scripts/debug/debug_plant.py similarity index 100% rename from astrape_ems/scripts/debug/debug_plant.py rename to scripts/debug/debug_plant.py diff --git a/astrape_ems/scripts/debug/modbus_test.py b/scripts/debug/modbus_test.py similarity index 100% rename from astrape_ems/scripts/debug/modbus_test.py rename to scripts/debug/modbus_test.py