diff --git a/CHANGELOG.md b/CHANGELOG.md index 080e8f0..1e7eabd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,16 @@ ## pyUpload (TKInter-Version 1.0) +- **2025-04-22 - v.1.0.2** +- Behoben + -- Wrapper-Skript `start.py` erkennt nun fehlende `.venv` und startet `main.py` beim Erststart korrekt mit System-Python, danach mit venv (`start.py`). + -- `main.py` verwendet unter Windows statt `os.execv()` nun `subprocess.Popen(..., CREATE_NEW_CONSOLE)` für einen sauberen Neustart mit sichtbarer Konsole (`main.py`). +- Entfernt + -- Nicht mehr benötigte Funktion `activate_venv()` entfernt (`main.py`). -- 2025-04-21 +- **2025-04-21 - v.1.0.1** - Geändert - `main.py` übernimmt nun automatisch die Erstellung der virtuellen Umgebung `.venv` und die Installation der Abhängigkeiten aus `requirements.txt` @@ -26,3 +32,6 @@ - PowerShell-Inkompatibilitäten mit `set /p` entfernt - `.cmd`-Startskripte reagieren jetzt korrekt auf STRG+C - Mehrere Markdown-Korrekturen (Codeblöcke, Leerzeilen, Lesbarkeit) + +- **2025-04-21 - v.1.0.0** + - release! diff --git a/VERSION b/VERSION index 7f20734..e6d5cb8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.2 \ No newline at end of file diff --git a/app/main.py b/app/main.py index 8fe8d24..29b76f8 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,9 @@ # © 2025 Adam Skotarczak (adam@skotarczak.net) # Dieses Softwarepaket darf nicht ohne Genehmigung weiterverbreitet werden! -# Version 1.0.0 (12.03.2025) +# +# Version 1.0.2 (22.04.2025 - virtuelle Umgebung korrekt aktiviert) +# Manuel in z.B VS-Code: .\app\.venv\Scripts\activate import os import sys @@ -16,17 +18,27 @@ VENV_DIR = os.path.join(BASE_DIR, ".venv") VENV_PYTHON = os.path.join(VENV_DIR, "Scripts", "python.exe") if os.name == "nt" else os.path.join(VENV_DIR, "bin", "python") REQUIREMENTS_FILE = os.path.join(BASE_DIR, "requirements.txt") -# Wenn wir NICHT in der venv sind → prüfen, ob venv existiert -if sys.prefix == sys.base_prefix and not os.path.exists(VENV_DIR): - print("[Setup] Virtuelle Umgebung wird erstellt...") - subprocess.run([sys.executable, "-m", "venv", "--copies", VENV_DIR], check=True) +# Wenn wir NICHT in der venv sind +if sys.prefix == sys.base_prefix: + # venv erstellen falls nötig + if not os.path.exists(VENV_DIR): + print("[Setup] Virtuelle Umgebung wird erstellt...") + subprocess.run([sys.executable, "-m", "venv", "--copies", VENV_DIR], check=True) - print("[Setup] requirements.txt wird installiert...") - subprocess.run([VENV_PYTHON, "-m", "pip", "install", "--upgrade", "pip"], check=True) - subprocess.run([VENV_PYTHON, "-m", "pip", "install", "-r", REQUIREMENTS_FILE], check=True) + print("[Setup] requirements.txt wird installiert...") + subprocess.run([VENV_PYTHON, "-m", "pip", "install", "--upgrade", "pip"], check=True) + subprocess.run([VENV_PYTHON, "-m", "pip", "install", "-r", REQUIREMENTS_FILE], check=True) + # unabhängig davon: Neustart innerhalb der venv print("[Setup] Starte erneut mit aktivierter Umgebung...") - os.execv(VENV_PYTHON, [VENV_PYTHON] + sys.argv) + + if os.name == "nt": + subprocess.Popen([VENV_PYTHON] + sys.argv, creationflags=subprocess.CREATE_NEW_CONSOLE) + else: + os.execv(VENV_PYTHON, [VENV_PYTHON] + sys.argv) + sys.exit(0) + + #os.execv(VENV_PYTHON, [VENV_PYTHON] + sys.argv) # Wir sind jetzt sicher in der richtigen Umgebung → Rest des Programms geht hier weiter: @@ -60,8 +72,6 @@ def activate_venv(): print(f"FEHLER: Virtuelle Umgebung nicht gefunden ({VENV_DIR}). Bitte zuerst install.cmd ausführen.") sys.exit(1) -activate_venv() - # ------------------------------------------------------------------- # Globale Konfigurationen & Logging # ------------------------------------------------------------------- diff --git a/start.pyw b/start.pyw index 7bd9594..7af4058 100644 --- a/start.pyw +++ b/start.pyw @@ -1,3 +1,16 @@ -import subprocess, os +#!/usr/bin/env python3 + +import os +import sys +import subprocess + os.chdir(os.path.dirname(__file__)) -subprocess.run(["python", "app/main.py"]) + +# Zielpfad zur venv-Python +venv_python = os.path.join("app", ".venv", "Scripts", "python.exe") if os.name == "nt" else os.path.join("app", ".venv", "bin", "python") + +# Verwende venv-Python, wenn vorhanden – sonst system-Python für initialen Aufbau +python_exec = venv_python if os.path.exists(venv_python) else sys.executable + +# Starte main.py +subprocess.run([python_exec, "app/main.py"] + sys.argv[1:])