or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tox-pyenv@1.1.x
tile.json

tessl/pypi-tox-pyenv

tessl install tessl/pypi-tox-pyenv@1.1.0

tox plugin that makes tox use `pyenv which` to find python executables

Agent Success

Agent success rate when using this tile

98%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.03x

Baseline

Agent success rate without this tile

95%

task.mdevals/scenario-7/

Python Version Validator

A command-line tool that validates whether specific Python versions are available through pyenv, with strict enforcement options.

Objective

Build a Python script that checks if one or more Python versions are available via pyenv. The tool should support both a lenient mode (falls back to system Python) and a strict mode (fails if pyenv doesn't have the version).

Requirements

Command-line Interface

The script should accept the following arguments:

  • --version or -v: One or more Python version strings to check (e.g., "python3.8", "python3.9")
  • --strict or -s: Enable strict mode (no fallback to system Python)

Behavior

Lenient Mode (default):

  • For each specified version, attempt to find the Python executable using pyenv
  • If pyenv returns a valid path, print: "Found <version> via pyenv: <path>"
  • If pyenv fails, fall back to checking the system PATH and print: "Found <version> via system: <path>"
  • If neither pyenv nor system PATH has the version, print: "Version <version> not found"

Strict Mode (--strict flag):

  • For each specified version, attempt to find the Python executable using pyenv only
  • If pyenv returns a valid path, print: "Found <version> via pyenv: <path>"
  • If pyenv fails to find the version, raise an exception and exit with code 1
  • Do not fall back to system Python under any circumstances

Implementation Notes

  • Use subprocess to call pyenv which <version>
  • Check subprocess exit codes to determine success/failure
  • Handle cases where pyenv binary is not installed
  • Capture and handle stderr output from pyenv

Test Cases

  • When pyenv finds python3.8, lenient mode prints the path @test
  • When pyenv fails but python3.8 exists in system PATH, lenient mode prints system path @test
  • When pyenv finds python3.9, strict mode prints the path @test
  • When pyenv fails in strict mode, an exception is raised @test

@generates

API

def find_python_executable(version: str, strict: bool = False) -> str:
    """
    Find Python executable for the given version.

    Args:
        version: Python version identifier (e.g., "python3.8")
        strict: If True, only use pyenv (no fallback to system)

    Returns:
        Path to the Python executable

    Raises:
        PyenvWhichFailed: When strict=True and pyenv cannot find the version
        PyenvMissing: When pyenv binary is not found on the system
    """
    pass

def main():
    """Parse arguments and validate Python versions."""
    pass

Dependencies { .dependencies }

tox-pyenv { .dependency }

Provides pyenv integration utilities and exception types for strict version enforcement.

@satisfied-by