Skip to content

refactor(venv): Extract pure VenvEngine from monolithic VenvManager - #14

Open
raidos23 wants to merge 1 commit into
mainfrom
venvmanager
Open

refactor(venv): Extract pure VenvEngine from monolithic VenvManager#14
raidos23 wants to merge 1 commit into
mainfrom
venvmanager

Conversation

@raidos23

@raidos23 raidos23 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Description

This PR refactors the virtual environment management system by extracting deterministic, pure Python logic from the monolithic VenvManager into a standalone, UI-independent VenvEngine.

Key Changes

  1. New VenvEngine module (venvengine.py):

    • Isolated all pure Python, synchronous inspection and execution logic (no Qt/UI dependencies, no event loop expectations).
    • Handles path resolution, strict venv validation (validate_venv_strict), tool binary discovery (has_tool_binary), preference file I/O (read_workspace_pref/write_workspace_pref), dependency analysis (can_use_system_python), and SHA-256 requirement markers (compute_file_hash).
    • Added prepare_manager_command and create_venv_sync for CLI and headless execution.
  2. Refactored VenvManager (Manager.py):

    • VenvManager now acts as an orchestrator / facade, delegating pure logic to self.engine while preserving 100% backwards compatibility for existing GUI/CLI flows.
    • Bug Fix: Fixed a double invocation loop in install_requirements_if_needed that previously triggered create_venv_if_needed twice during pycompiler_ark init --with-venv.
  3. Unit Tests (tests/test_venv_engine.py):

    • Added a dedicated test suite for VenvEngine testing path resolution, strict validation, requirement markers, command preparation, and preference management.

Verification and Testing

  • All 34 unit tests passed cleanly (python3 -m unittest discover -s tests).
  • Verified pycompiler_ark init --entry ark.yml --with-venv CLI execution without duplicate log output.

Checklist

  • Code is properly typed and formatted.
  • No breaking changes to the existing VenvManager public API.
  • Unit tests added and passing.

…rations

Signed-off-by: Samuel Amen Ague <ague.samuel27@gmail.com>
Repository owner deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant