Skip to content

Interaction with toxΒ #211

@clint-lawrence

Description

@clint-lawrence

tox doesn't pass LOCALAPPDATA to subcommands by default, so when calling py.exe from a tox command, it can't find any runtimes, even when they are installed.

I'm planning to raise in issue on the tox project to pass that env var on windows. Is there is anything else that is needed to ensure tox and py.exe work correctly together?

Background

Installed using version 20.1b1 as documented here https://www.python.org/downloads/release/pymanager-251b1/

Details

I have a python script that is called by tox. This script calls py.exe with a specific python version set. Running this script directly with py.exe works fine as expected. Something like:

import subprocess
subprocess.run(["py.exe", "-V:3.12", "-c", "pass"], check=True)

And a tox file

[testenv]
commands =
    python call_py.py

When running tox, the subprocess call to py.exe fails with following error.

❯ uvx tox
py: commands[0]> python call_py.py
[ERROR] No runtime installed that matches 3.12. Try running "py install 3.12".
Traceback (most recent call last):
  File "C:\Users\clawrence\dev\pymanager\call_py.py", line 3, in <module>
    subprocess.run(["py.exe", "-V:3.12", "-c", "pass"], check=True)
  File "C:\Users\clawrence\AppData\Roaming\uv\python\cpython-3.10.18-windows-x86_64-none\lib\subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['py.exe', '-V:3.12', '-c', 'pass']' returned non-zero exit status 2684354566.
py: exit 1 (0.80 seconds) C:\Users\clawrence\dev\pymanager> python call_py.py pid=19416
  py: FAIL code 1 (1.08=setup[0.28]+cmd[0.80] seconds)
  evaluation failed :( (1.16 seconds)

~\dev\pymanager via 🐍 v3.14.0 (installer) took 3s
❯ py -V:3.12 -c "pass"

~\dev\pymanager via 🐍 v3.14.0 (installer)
❯ py call_py.py

~\dev\pymanager via 🐍 v3.14.0 (installer)
❯

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions