Skip to content

Make :PymodeRun execute with the activated virtualenv interpreter#1200

Draft
Copilot wants to merge 4 commits into
developfrom
copilot/fix-venv-activation-issue
Draft

Make :PymodeRun execute with the activated virtualenv interpreter#1200
Copilot wants to merge 4 commits into
developfrom
copilot/fix-venv-activation-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

Pymode correctly detected/activated virtualenvs, but :PymodeRun still executed code with Vim’s embedded/system Python, causing version mismatch (e.g. active 3.13 venv, output from 3.14 system Python).
This change aligns run behavior with virtualenv activation so executed code uses the selected environment interpreter.

  • Run-path correction for virtualenv-enabled sessions

    • Updated pymode/run.py so run_code() checks g:pymode_virtualenv_enabled and resolves the venv Python executable (bin/python on Unix, Scripts/python.exe on Windows).
    • When available, code is executed via that interpreter through a temp script + subprocess, preserving cwd and capturing stdout/stderr for existing quickfix/output flow.
    • Keeps existing in-process execution path as fallback when no active virtualenv interpreter is available.
  • Regression coverage

    • Added a focused Vader test in tests/vader/commands.vader that:
      • creates a temporary virtualenv,
      • activates it with :PymodeVirtualenv,
      • runs :PymodeRun,
      • asserts __run__ output includes the venv interpreter path.
  • Docs update

    • Clarified in doc/pymode.txt that :PymodeRun uses the virtualenv Python executable when virtualenv is activated.
# before: often printed system interpreter from Vim host runtime
import sys
print(sys.executable)

# after: with :PymodeVirtualenv .venv, prints .../.venv/bin/python (or Scripts/python.exe)

Copilot AI linked an issue Apr 21, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

🧪 Test Results Summary

This comment will be updated automatically as tests complete.

Python linux-3.10 ✅

  • Status: PASSED
  • Python Version: 3.10.20
  • Vim Version: 9.1
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python linux-3.11 ✅

  • Status: PASSED
  • Python Version: 3.11.15
  • Vim Version: 9.1
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python linux-3.12 ✅

  • Status: PASSED
  • Python Version: 3.12.13
  • Vim Version: 9.1
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python linux-3.13 ✅

  • Status: PASSED
  • Python Version: 3.13.13
  • Vim Version: 9.1
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python linux-3.14 ✅

  • Status: PASSED
  • Python Version: 3.14.4
  • Vim Version: 9.1
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python macos-3.10 ✅

  • Status: PASSED
  • Python Version: 3.14.4
  • Vim Version: 9.2
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python macos-3.11 ✅

  • Status: PASSED
  • Python Version: 3.14.4
  • Vim Version: 9.2
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python macos-3.12 ✅

  • Status: PASSED
  • Python Version: 3.14.4
  • Vim Version: 9.2
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python macos-3.13 ✅

  • Status: PASSED
  • Python Version: 3.14.4
  • Vim Version: 9.2
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python windows-3.10 ✅

  • Status: PASSED
  • Python Version: 3.10.11
  • Vim Version: ed
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python windows-3.11 ✅

  • Status: PASSED
  • Python Version: 3.11.9
  • Vim Version: ed
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python windows-3.12 ✅

  • Status: PASSED
  • Python Version: 3.12.10
  • Vim Version: ed
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

Python windows-3.13 ✅

  • Status: PASSED
  • Python Version: 3.13.13
  • Vim Version: ed
  • Tests: 9/9 passed
  • Assertions: 99/107 passed

📊 Overall Summary

  • Python Versions Tested: 13
  • Total Tests: 117
  • Passed: 117
  • Failed: 0
  • Total Assertions: 1391
  • Passed Assertions: 1287

🎉 All tests passed across all Python versions!


Generated automatically by CI/CD workflow

Copilot AI changed the title [WIP] Fix virtual environment activation issue in Pymode Make :PymodeRun execute with the activated virtualenv interpreter Apr 21, 2026
Copilot AI requested a review from diraol April 21, 2026 20:48
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.

trouble with venv

2 participants