Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: "uv venv" gives "exit 2" with tox-uv #1636

Closed
hugovk opened this issue Feb 18, 2024 · 11 comments · Fixed by #2171
Closed

Windows: "uv venv" gives "exit 2" with tox-uv #1636

hugovk opened this issue Feb 18, 2024 · 11 comments · Fixed by #2171
Assignees
Labels
bug Something isn't working virtualenv Related to virtual environments windows Specific to the Windows platform

Comments

@hugovk
Copy link

hugovk commented Feb 18, 2024

Windows
uv 0.1.4
tox-uv 1.2.0

Using tox-uv, and running python -m tox -e py -vvv on Windows with CPython 3.8-3.13 and PyPy 3.10 gives an error:

ROOT: 156 D setup logging to NOTSET on pid 8056 [tox\report.py:221]
py: 375 W venv> C:\hostedtoolcache\windows\Python\3.8.10\x64\uv venv -p 3.8 D:\a\termcolor\termcolor\.tox\py\.venv [tox\tox_env\api.py:427]
py: 375 C exit 2 (0.00 seconds) D:\a\termcolor\termcolor> C:\hostedtoolcache\windows\Python\3.8.10\x64\uv venv -p 3.8 D:\a\termcolor\termcolor\.tox\py\.venv [tox\execute\api.py:280]
  py: FAIL code 2 (0.00 seconds)
  evaluation failed :( (0.22 seconds)
Error: Process completed with exit code 1.

It passes on Ubuntu and macOS. I don't have a Windows machine, this is on CI:

https://github.com/hugovk/termcolor/actions/runs/7948092300/job/21697697387

To get the code locally:

git clone https://github.com/hugovk/termcolor/
git checkout fd9f3f426449541a111560585c4230e31d2e0adf

Possibly a tox-uv bug?

@MichaReiser MichaReiser added the windows Specific to the Windows platform label Feb 18, 2024
@zanieb zanieb added the virtualenv Related to virtual environments label Feb 18, 2024
@ofek
Copy link
Contributor

ofek commented Feb 18, 2024

#1310

@zanieb zanieb added the bug Something isn't working label Feb 18, 2024
@hugovk
Copy link
Author

hugovk commented Mar 4, 2024

Reproducible on Windows with uv 0.1.14 for PyPy 3.9 and 3.10, and CPython 3.13 (via tox-uv 1.4.0):

Run python -m tox -e py -rvvv
.pkg: 4423 W remove tox env folder D:\a\termcolor\termcolor\.tox\.pkg [tox\tox_env\api.py:325]
py: 4470 W venv> C:\hostedtoolcache\windows\PyPy\3.10.13\x86\Scripts\uv.exe venv -p 3.10 -v D:\a\termcolor\termcolor\.tox\py\.venv [tox\tox_env\api.py:427]
 uv_interpreter::python_query::find_requested_python request=3.10
      0.002894s   0ms DEBUG uv_interpreter::python_query Starting interpreter discovery for Python @ `3.10`
      0.003287s   0ms DEBUG uv_interpreter::interpreter Probing interpreter info for: C:\hostedtoolcache\windows\PyPy\3.10.13\x86\python3.10.exe
      0.132933s 130ms DEBUG uv_interpreter::interpreter Found Python 3.10.13 for: C:\hostedtoolcache\windows\PyPy\3.10.13\x86\python3.10.exe
Using Python 3.10.13 interpreter at: C:\hostedtoolcache\windows\PyPy\3.10.13\x86\python3.10.exe
Creating virtualenv at: D:\a\termcolor\termcolor\.tox\py\.venv
uv::venv::creation

  × Failed to create virtualenv
  ├─▶ failed to copy file from
  │   C:\hostedtoolcache\windows\PyPy\3.10.13\x86\Lib\venv\scripts\nt\python.exe
  │   to \\?\D:\a\termcolor\termcolor\.tox\py\.venv\Scripts\python.exe
  ╰─▶ The system cannot find the file specified. (os error 2)
py: 5080 C exit 1 (0.61 seconds) D:\a\termcolor\termcolor> C:\hostedtoolcache\windows\PyPy\3.10.13\x86\Scripts\uv.exe venv -p 3.10 -v D:\a\termcolor\termcolor\.tox\py\.venv pid=6192 [tox\execute\api.py:280]
  py: FAIL code 1 (0.67 seconds)
  evaluation failed :( (4.67 seconds)

Error: Process completed with exit code 1.

https://github.com/hugovk/termcolor/actions/runs/8145079624

CPython 3.8-3.12 pass.

@charliermarsh
Copy link
Member

Thanks, let me see if I can repro with a minimal Python 3.13 run.

@charliermarsh
Copy link
Member

Reproduced here, thanks! #2171

@charliermarsh charliermarsh self-assigned this Mar 4, 2024
@charliermarsh
Copy link
Member

First trying to figure out if we're attempting to copy from the wrong directory, or if we're copying the wrong filename.

@charliermarsh
Copy link
Member

@gaborbernat - Do you know if the development builds exclude the venv shims?

@charliermarsh
Copy link
Member

I figured this out, I think we're supposed to fallback to venvlauncher.exe if python.exe doesn't exist:

https://github.com/python/cpython/blob/d457345bbc6414db0443819290b04a9a4333313d/Lib/venv/__init__.py#L270C66-L270C71

@charliermarsh
Copy link
Member

I asked a question about it on discuss: https://discuss.python.org/t/when-should-venv-scripts-nt-python-exe-be-present/47620

charliermarsh added a commit that referenced this issue Mar 4, 2024
## Summary

In Python 3.13, at least in the current builds, there's no `python.exe`,
but there is `venvlauncher.exe`.

I've asked here about whether it's intended:
https://discuss.python.org/t/when-should-venv-scripts-nt-python-exe-be-present/47620.
But there's at least some evidence in CPython
[here](https://github.com/python/cpython/blob/d457345bbc6414db0443819290b04a9a4333313d/Lib/venv/__init__.py#L270)
that we should fall back to these, and the tests pass.

Closes #1636.
@charliermarsh
Copy link
Member

FYI @gaborbernat -- The executable names changed in Python 3.13: https://discuss.python.org/t/when-should-venv-scripts-nt-python-exe-be-present/47620/2. I suspect virtualenv won't fail because it's robust to the shims not existing.

@hugovk
Copy link
Author

hugovk commented Mar 5, 2024

Thanks for the CPython 3.13 fix!

This issue is also about PyPy (3.9 and 3.10), does uv need an extra fix there?

@AlexWaygood
Copy link
Member

This issue is also about PyPy (3.9 and 3.10), does uv need an extra fix there?

Probably — PyPy isn't officially supported right now, though we'd welcome contributions to help us get there! See #2096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working virtualenv Related to virtual environments windows Specific to the Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants