neuro/src/bootstrap.py
2026-03-01 00:51:56 +01:00

41 lines
1.1 KiB
Python

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"NEURO {getattr(self, 'version', '')} — inicializador de ambiente")
def run(self):
self._ensure_venv()
self.launch_neuro()
def _ensure_venv(self):
os.chdir(self.base_path)
if not self.venv_path.exists():
print("[+] Criando ambiente Python...")
subprocess.run(
[sys.executable, "-m", "venv", str(self.venv_path)],
check=True
)
else:
print("[=] Ambiente Python já existente.")
def launch_neuro(self):
neuro = self.base_path / "src" / "root" / "__main__.py"
subprocess.run([str(self.python), str(neuro)])