Skip to content

Commit be1bc2c

Browse files
committed
Refactor VenvManager and MainWindow to delegate output handling to VenvManager
1 parent 9f54e6b commit be1bc2c

2 files changed

Lines changed: 32 additions & 15 deletions

File tree

Core/MainWindow.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -532,24 +532,10 @@ def select_venv_manually(self):
532532
def create_venv_if_needed(self, path):
533533
self.venv_manager.create_venv_if_needed(path)
534534

535-
def _on_venv_output(self, process, error=False):
536-
# Delegated to venv_manager
537-
pass
538-
539-
def _on_venv_created(self, process, code, status, venv_path):
540-
# Delegated to venv_manager
541-
pass
542-
543535
def install_requirements_if_needed(self, path):
544536
self.venv_manager.install_requirements_if_needed(path)
545537

546-
def _on_pip_output(self, process, error=False):
547-
# Delegated to venv_manager
548-
pass
549538

550-
def _on_pip_finished(self, process, code, status):
551-
# Delegated to venv_manager
552-
pass
553539

554540
def select_files_manually(self):
555541
if not self.workspace_dir:

Core/Venv_Manager/Manager.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,24 +2047,55 @@ def _on_manager_install_finished(self, process, code, status, manager):
20472047

20482048
QApplication.processEvents()
20492049

2050-
def setup_workspace(self, workspace_dir: str) -> bool:
2050+
def setup_workspace(self, workspace_dir: str, check_tools: bool = True) -> bool:
20512051
"""Setup a workspace with venv and dependencies.
20522052
20532053
This centralizes the workspace setup logic that was previously
20542054
scattered in MainWindow.apply_workspace_selection().
20552055
20562056
Args:
20572057
workspace_dir: Path to the workspace directory
2058+
check_tools: Whether to check and install tools (pyinstaller, nuitka, cx_freeze)
2059+
after venv creation. Defaults to True.
20582060
20592061
Returns:
20602062
bool: True if setup successful, False otherwise
20612063
"""
20622064
try:
20632065
workspace_dir = os.path.abspath(workspace_dir)
20642066

2067+
# Resolve venv path first to check if it exists
2068+
existing, default_path = self._detect_venv_in(workspace_dir)
2069+
venv_path = existing or default_path
2070+
20652071
# Create venv if needed
20662072
self.create_venv_if_needed(workspace_dir)
20672073

2074+
# Check and install tools if requested
2075+
if check_tools:
2076+
# Verify venv exists and is valid before checking tools
2077+
existing_check, _ = self._detect_venv_in(workspace_dir)
2078+
if existing_check:
2079+
ok, reason = self.validate_venv_strict(existing_check)
2080+
if ok:
2081+
# Verify binding and then check tools
2082+
def _after_binding(ok_bind: bool):
2083+
if ok_bind:
2084+
self._safe_log(
2085+
"🔍 Vérification des outils de compilation..."
2086+
)
2087+
self.check_tools_in_venv(existing_check)
2088+
else:
2089+
self._safe_log(
2090+
"⚠️ Liaison venv invalide, vérification des outils ignorée."
2091+
)
2092+
2093+
self._verify_venv_binding_async(existing_check, _after_binding)
2094+
else:
2095+
self._safe_log(
2096+
f"⚠️ Venv invalide, vérification des outils ignorée: {reason}"
2097+
)
2098+
20682099
# Create ARK config if it doesn't exist
20692100
try:
20702101
from Core.ark_config_loader import create_default_ark_config

0 commit comments

Comments
 (0)