"Auto-commit via make git"

This commit is contained in:
neo.webmaster.2@gmail.com 2026-03-04 08:36:07 +01:00
parent 51b9a2392d
commit f6c5409986
6 changed files with 63 additions and 8 deletions

View File

@ -113,7 +113,7 @@ check-remote:
# Teste
# ===========================
run:
@python3 src/neuro/__main__.py
@python3 src/lab/__main__.py
# ===========================
# Limpeza

View File

@ -1,18 +1,18 @@
SUBDIRS = neuro
bin_SCRIPTS = neuro
bin_SCRIPTS = myhomelab
CLEANFILES = $(bin_SCRIPTS)
EXTRA_DIST = neuro.in
EXTRA_DIST = myhomelab.in
# ===========================
# Substituição dinâmica
# ===========================
neuro: neuro.in Makefile
myhomelab: myhomelab.in Makefile
@which git >/dev/null || { echo "⚠️ Git não encontrado — instale-o manualmente."; exit 1; }
sed \
-e 's,[@]pythondir[@],$(pythondir),g' \
-e 's,[@]PACKAGE[@],$(PACKAGE),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
< $(srcdir)/neuro.in > neuro
chmod +x neuro
< $(srcdir)/myhomelab.in > myhomelab
chmod +x myhomelab

43
src/bootstrap.py Normal file
View File

@ -0,0 +1,43 @@
from pathlib import Path
import subprocess
import sys
import os
class Application(object):
def __init__(self, *args, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
self.base_path = Path(__file__).resolve().parents[1]
self.venv_path = self.base_path / "venv"
self.python = self.venv_path / "bin" / "python"
self._hello()
def _hello(self):
print(f"Iniciando o {getattr(self, 'package', '')} {getattr(self, 'version', '')}...")
def _print(self, msg: str):
print(f"[{getattr(self, 'package', '')}] {msg}", flush=True)
def run(self):
self._ensure_venv()
self.launch_neuro()
def _ensure_venv(self):
os.chdir(self.base_path)
if not self.venv_path.exists():
self._print("Criando ambiente Python...")
subprocess.run(
[sys.executable, "-m", "venv", str(self.venv_path)],
check=True
)
else:
self._print("Ambiente Python já existente.")
def launch_neuro(self):
neuro = self.base_path / "src" / "neuro" / "__main__.py"
subprocess.run([str(self.python), str(neuro)])

10
src/myhomelab Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
import sys
sys.path.insert(1, '/usr/local/local/lib/python3.12/dist-packages')
from bootstrap import Application
if __name__ == "__main__":
app = Application(package="myhomelab", version="51b9a23-dirty")
app.run()

View File

@ -8,4 +8,3 @@ from bootstrap import Application
if __name__ == "__main__":
app = Application(package="@PACKAGE@", version="@VERSION@")
app.run()

View File

@ -10,4 +10,7 @@ dist_neuro_PYTHON = \
__main__.py \
__init__.py
# Inclui o bootstrap (nível acima) como parte deste pacote
EXTRA_DIST = ../bootstrap.py