Skip to content

feat: support Windows Python venv executables in pytest/mypy/pip-audit#54

Merged
thefourcraft merged 2 commits intoproductionfrom
feature/windows-python-venv-tools
May 4, 2026
Merged

feat: support Windows Python venv executables in pytest/mypy/pip-audit#54
thefourcraft merged 2 commits intoproductionfrom
feature/windows-python-venv-tools

Conversation

@thefourcraft
Copy link
Copy Markdown
Member

Summary

Windows virtualenvs place tool binaries at .venv\Scripts\<tool>.exe rather than .venv/bin/<tool>. All three Python runners (pytest, mypy, pip-audit) were only checking the POSIX path and would miss locally-installed tools on Windows.

  • New shared helper src/runners/python_venv.rs::venv_tool(root, name) tries POSIX first, then Windows, returns None to fall back to PATH
  • is_available, run, and has_pytest_cov in all three runners now use venv_tool instead of hard-coded .venv/bin/ paths
  • Fallback to system PATH is unchanged when neither local path exists

Test plan

pytest

  • available_via_windows_scripts_exe.venv/Scripts/pytest.exe makes is_available return true
  • run_uses_windows_venv_pytest_exerun() passes .venv/Scripts/pytest.exe as the command

mypy

  • available_via_windows_scripts_exe.venv/Scripts/mypy.exe makes is_available return true
  • run_uses_windows_venv_mypy_exerun() passes .venv/Scripts/mypy.exe as the command

pip-audit

  • available_via_windows_scripts_exe.venv/Scripts/pip-audit.exe makes is_available return true

  • run_uses_windows_venv_pip_audit_exerun() passes .venv/Scripts/pip-audit.exe as the command

  • All 746 tests pass (including existing POSIX and PATH fallback tests)

  • cargo clippy --bin barzel -- -D warnings clean

  • git diff --check production..HEAD clean

Windows virtualenvs place tool binaries under .venv/Scripts/<tool>.exe
rather than .venv/bin/<tool>.  All three Python runners now check both
paths via a shared venv_tool() helper in runners/python_venv.rs:

1. POSIX path (.venv/bin/<tool>) is preferred when it exists
2. Windows path (.venv/Scripts/<tool>.exe) is checked second
3. Falls back to PATH when neither local path exists

has_pytest_cov coverage detection also uses venv_tool() so Windows
venvs get coverage metrics too.
has_pytest_cov was POSIX-only for site-packages scanning.  It now also
checks .venv/Lib/site-packages/pytest_cov (Windows venv layout) when
.venv/Scripts/pytest.exe is present, so coverage metrics are reported
on Windows the same way they are on POSIX.
@thefourcraft thefourcraft merged commit fdbb502 into production May 4, 2026
11 checks passed
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