Skip to content

Conversation

@ppentchev
Copy link
Contributor

Hi,

Thanks a lot for writing and maintaining tox-uv, as well as for all your work in the Python ecosystem!

Now, I have a somewhat unusual setup: a vendor-specific Python interpreter that is not in the normal search path. Since I'd like to use tox-uv to test that my modules will also be compatible with that version, I have a virtual environment with tox and tox-uv (and, actually, also test-stages for the tox-stages utility); however, a stock installation of tox-uv within such a virtual environment passes "-p 3.8" to uv, and since python3.8 is not in the search path, that fails.

What do you think about this change that uses sys.executable if the major and minor Python version are the same as the currently running interpreter?

Thanks in advance, and keep up the great work!

G'luck,
Peter

PS. Yes, Python 3.8 is too old; still, it is what it is :)

Support the case when pythonX.Y is not in the search path, but
it corresponds to the currently running Python interpreter.

This may happen if e.g. Tox is installed (along with tox-uv) in
a virtual environment that has been created with a Python interpreter
coming from a non-standard location, and then `tox` is invoked
directly from the virtual environment's `bin/` directory:

    [roam@straylight ~]$ mkdir ~/not-in-path

    [roam@straylight ~]$ uv venv -p /opt/some-vendor/python3/bin/python3 ~/not-in-path/venv
    Using Python 3.8.17 interpreter at: /opt/some-vendor/python3/bin/python3
    Creating virtualenv at: /home/roam/not-in-path/venv
    Activate with: source /home/roam/not-in-path/venv/bin/activate

    [roam@straylight ~]$ (set -e; . ~/not-in-path/venv/bin/activate; uv pip install tox tox-uv)
    ...snip...

    [roam@straylight ~]$ printf -- '%s\n' '[testenv]' 'package=skip' 'commands=python3 -c "print()"' > ~/not-in-path/tox.ini

    [roam@straylight ~]$ ~/not-in-path/venv/bin/tox -c ~/not-in-path/tox.ini
    py: venv /home/roam/not-in-path> venv/bin/uv venv -p 3.8 /home/roam/not-in-path/.tox/py/.venv
      × No Python 3.8 in `PATH`. Is Python 3.8 installed?
    py: exit 1 (0.01 seconds) /home/roam/not-in-path> venv/bin/uv venv -p 3.8 /home/roam/not-in-path/.tox/py/.venv pid=1059253
      py: FAIL code 1 (0.02 seconds)
      evaluation failed :( (0.11 seconds)

    [roam@straylight ~]$
@ppentchev ppentchev requested a review from gaborbernat as a code owner March 15, 2024 21:06
gaborbernat
gaborbernat previously approved these changes Mar 15, 2024
@gaborbernat
Copy link
Member

You'll need to get the CI to pass 👍

@ppentchev
Copy link
Contributor Author

I'm sorry... I know you may find this hard to believe, but I did actually run both the "fix" and "type" environments successfully - for an earlier version of the patch. Then I changed things around, and I only ran "fix" partially through my editor, and it hid the error from me because of the weird way I invoked it... and I forgot to run them for real.

@gaborbernat
Copy link
Member

No worries it's all good 😊

@gaborbernat gaborbernat merged commit 04363ff into tox-dev:main Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants