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-8/

Python Environment Fallback Handler

A tox plugin that implements a fallback mechanism for Python executable discovery, attempting to use a primary version manager before falling back to the system's default Python discovery.

Capabilities

Primary version manager discovery

  • When given basepython "python3.8" and the primary manager successfully returns "/usr/local/bin/python3.8", the function returns that path @test
  • When given basepython "python2.7" and the primary manager successfully returns "/opt/python/2.7/bin/python2.7", the function returns that path @test

Fallback to default discovery

  • When the primary manager command fails with exit code 1, the function returns None to allow tox's default discovery @test
  • When the primary manager raises an OSError (command not found), the function returns None to allow tox's default discovery @test

Error handling

  • When the primary manager returns an empty string, the function returns None to trigger fallback @test

Implementation

@generates

API

import subprocess
from typing import Optional

def get_python_executable(basepython: str, primary_command: str) -> Optional[str]:
    """
    Attempts to discover Python executable using a primary command, falling back to None.

    Args:
        basepython: The target Python version identifier (e.g., "python3.8", "python2.7")
        primary_command: The command to use for primary discovery (e.g., "pyenv")

    Returns:
        The full path to the Python executable if found via primary command,
        or None to signal that tox should use its default discovery mechanism.

    The function executes: `<primary_command> which <basepython>`
    """
    pass