@tox_hookimpl<EOL>def tox_get_python_executable(envconfig):
try:<EOL><INDENT>pyenv = (getattr(py.path.local.sysfind('<STR_LIT>'), '<STR_LIT>', '<STR_LIT>')<EOL>or '<STR_LIT>')<EOL>cmd = [pyenv, '<STR_LIT>', envconfig.basepython]<EOL>pipe = subprocess.Popen(<EOL>cmd,<EOL>stdout=subprocess.PIPE,<EOL>stderr=subprocess.PIPE,<EOL>universal_newlines=True<EOL>)<EOL>out, err = pipe.communicate()<EOL><DEDENT>except OSError:<EOL><INDENT>err = '<STR_LIT>'<EOL>LOG.warning(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>else:<EOL><INDENT>if pipe.poll() == <NUM_LIT:0>:<EOL><INDENT>return out.strip()<EOL><DEDENT>else:<EOL><INDENT>if not envconfig.tox_pyenv_fallback:<EOL><INDENT>raise PyenvWhichFailed(err)<EOL><DEDENT><DEDENT><DEDENT>LOG.debug("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>'<STR_LIT:U+0020>'.join([str(x) for x in cmd]), err)<EOL>
Return a python executable for the given python base name.

    The first plugin/hook which returns an executable path will determine it.

    ``envconfig`` is the testenv configuration which contains
    per-testenv configuration, notably the ``.envname`` and ``.basepython``
    setting.