<#9394 fix: Recreate venv when plugin Python versi...
# meltano-repo-activity
g
#9394 fix: Recreate venv when plugin Python version is changed Pull request opened by mahangu Hi! 👋🏾 I wanted to try my hand at something beyond a
good first issue
but I'm still very new to Meltano's codebase so this is very much a Draft PR. It may not even be what the team is looking for at all, as I see #9391 in the works too. However, I believe that this PR could be complementary to the work in that one. Thank you for taking a look! Edit: My apologies, I just saw that #9390 doesn't have
Accepting Pull Requests
as a label so maybe you're not looking for a PR for it.
🙏🏾 ## Overview This draft PR looks to address the core technical issue described in #9390 where virtual environments are not recreated when a plugin's Python version setting changes, causing installations to fail even after switching to a compatible Python version. ## Problem When adding a plugin with a specific Python version that fails (e.g.,
meltano add target-gcs --python 3.13
), subsequent attempts with a different Python version (e.g.,
meltano add target-gcs --python 3.11
) continue to fail because the existing virtual environment fingerprint doesn't account for Python version changes. ## Solution This draft PR enhances the virtual environment fingerprinting mechanism to include the Python interpreter path when it differs from the default, ensuring that changes to the Python version automatically trigger virtual environment recreation while maintaining backward compatibility. ### Changes Made • Enhanced
fingerprint()
function to include Python interpreter path only when it differs from
sys.executable
• Updated
VirtualEnv.write_fingerprint()
to pass Python path to fingerprint • Modified
requires_clean_install()
to detect Python version changes • Added tests ## Relationship to PR #9391 PR #9391 by @edgarrmondragon is more expansive and improves the plugin addition workflow UX by making
meltano add
idempotent. These changes appear to be complementary: • PR #9391: Improves user experience by allowing plugin configuration updates • This draft PR: Looks to ensure the underlying virtual environment system responds correctly to Python version changes Both changes address different layers of the same user problem and could potentially work together or independently. The files modified don't overlap, so there appear to be no merge conflicts. ## Testing • Added unit tests for fingerprint function with Python path variations • Added integration tests for Python version change detection ## Impact This attempts to be a minimal, targeted fix that preserves all existing behavior while addressing the specific technical issue. Virtual environments created before this change work normally (no fingerprint changes for default Python), and the fix only activates when specific Python versions are explicitly set and later changed. Looks to address #9390 ## Summary by Sourcery Extend the virtual environment fingerprint to account for custom Python interpreter paths and trigger recreation when a plugin’s Python version changes Bug Fixes: • Recreate virtual environments when a plugin's Python version setting changes Enhancements: • Include Python interpreter path in the pip install fingerprint when it differs from the default • Update VenvService to write and compare fingerprints with the Python path Tests: • Add unit tests for fingerprint variations with Python path • Add integration tests for detecting Python version changes in requires_clean_install ## Summary by Sourcery Ensure virtual environments are recreated when a plugin’s Python version setting changes by including the Python interpreter path in the fingerprint comparison. Bug Fixes: • Recreate virtual environment when a plugin's Python version setting changes Enhancements: • Extend fingerprinting to include Python interpreter path when it differs from the default • Update write_fingerprint and requires_clean_install to pass and compare python_path Tests: • Add unit tests for fingerprint behavior with different Python paths • Add integration test for detecting Python version changes in requires_clean_install meltano/meltano