GitHub
07/03/2025, 5:53 PMpython project and plugin setting, rely on the venv.backend to discover the correct Python executable
Pull request opened by edgarrmondragon
## Description
This allows uv to download and install Python versions if they're not found locally.
Example:
# Starting on a fresh Meltano on Python 3.13 in Docker
$ uv python list | grep -v "available"
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python3.13
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python3 -> python3.13
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python -> python3
$ meltano init --no-usage-stats project
$ cd project
$ meltano add --python 3.9 target-jsonl
# Notice that uv downloaded Python 3.9!
$ uv python list | grep -v "available"
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python3.13
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python3 -> python3.13
cpython-3.13.5-linux-aarch64-gnu /usr/local/bin/python -> python3
cpython-3.9.23-linux-aarch64-gnu /root/.local/share/uv/python/cpython-3.9.23-linux-aarch64-gnu/bin/python3.9
# Switching then to virtualenv fails to find the uv-managed Python, but I'll report this to them
$ MELTANO_VENV_BACKEND=virtualenv meltano install --clean
CliError: Failed to install plugin(s)
## Related Issues
• pypa/virtualenv#2901
## Summary by Sourcery
Delegate Python executable resolution to the virtual environment backend by removing internal resolution logic, simplifying VirtualEnv initialization, and updating services to pass raw Python version or path; introduce plugin-level Python setting and a factory method for service instantiation, and update tests and documentation to reflect these changes.
New Features:
• Add python attribute to ProjectPlugin to store specified Python version or path
• Introduce VenvService.from_plugin class method to create service instances with plugin-level settings
Enhancements:
• Remove internal _resolve_python_path logic and delegate Python executable discovery to the virtual environment backend
• Simplify VirtualEnv initialization to assign python_path directly from the provided string or default to sys.executable
• Pass raw Python version/path to exec_async when creating virtual environments in VenvService and UvVenvService
• Use a default stderr extractor in create_venv methods
Documentation:
• Clarify CLI docs to describe the --python option as accepting a Python version or path
Tests:
• Refactor tests to patch exec_async and verify the Python argument passed to the venv backend
• Remove obsolete tests around _resolve_python_path and legacy virtual environment creation
## Summary by Sourcery
Allow specifying plugin- and project-level Python versions or paths and delegate executable discovery to the venv backend by removing internal resolution logic, simplifying VirtualEnv initialization, standardizing --python= flags in service calls, and updating tests and documentation.
New Features:
• Add a python attribute to ProjectPlugin to store user-specified Python version or path
• Introduce a VenvService.from_plugin factory method to initialize services with plugin-level Python settings
Enhancements:
• Remove the internal _resolve_python_path logic and rely on the virtual environment backend for executable discovery
• Simplify VirtualEnv to set python_path directly from the provided value or default to sys.executable
• Standardize venv and pip commands to use --python=<path> flags instead of separate arguments
Documentation:
• Clarify the CLI --python option as accepting a Python version or path
Tests:
• Refactor tests to patch exec_async and assert --python= flags, removing obsolete resolution tests
meltano/meltanoGitHub
07/03/2025, 5:53 PMGitHub
07/03/2025, 6:18 PM