uv icon indicating copy to clipboard operation
uv copied to clipboard

How can I integrate `tox` into `uv`?

Open paddyroddy opened this issue 1 year ago • 10 comments

I find that tox can take a long time to install dependencies (longer than doing it locally), it would be nice to benefit from uv for this. Think that the relevant bit in tox is here.

paddyroddy avatar Feb 16 '24 12:02 paddyroddy

https://tox.wiki/en/latest/config.html#install_command looks to be a possible solution to putting uv in place of pip

atmartinez avatar Feb 16 '24 15:02 atmartinez

No, It does not allow as uv is not installed in venv, and you cannot install it when you change install command...

To help myself with this task, I started implementing tox plugin. https://github.com/Czaki/tox-uv

But I hit the bug in uv it do not allow to install with full path to wheel file:

py311-macos-pyqt5-no_cov: install_package> python -I -m uv pip install --force-reinstall --no-deps /tmp/.tox/.tmp/package/5/napari-0.5.0a2.dev578+g17b00de2.tar.gz
error: Failed to parse `/tmp/.tox/.tmp/package/5/napari-0.5.0a2.dev578+g17b00de2.tar.gz`
  Caused by: Expected package name starting with an alphanumeric character, found '/'
/tmp/.tox/.tmp/package/5/napari-0.5.0a2.dev578+g17b00de2.tar.gz

Czaki avatar Feb 16 '24 16:02 Czaki

@Czaki -- We can install via a full path, we just require a package name right now (like napari @ /tmp/.tox/.tmp/package/5/napari-0.5.0a2.dev578+g17b00de2.tar.gz).

charliermarsh avatar Feb 16 '24 16:02 charliermarsh

@charliermarsh Ok. I do not control this part of tox, and it will need to do hacking that may not be stable. Why provide a full path to sdist or wheel is not enough and require extracting it from the file name?

Czaki avatar Feb 16 '24 16:02 Czaki

It's just not implemented yet. In general, we can't read the package name from sdist files (like the one you linked -- that looks like an sdist?) since it doesn't follow any particular spec. Wheels do follow a spec and so we could read the package name from the filename in that case.

charliermarsh avatar Feb 16 '24 16:02 charliermarsh

python -m build --sdist do not follow any spec?

Czaki avatar Feb 16 '24 16:02 Czaki

Ok. I have created a workaround. It works nice with wheels, but end with error for sdist:

⠹ Resolving dependencies...                                                                              thread 'main' panicked at crates/uv-resolver/src/resolution.rs:120:26:
Every package should have metadata
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
py311-macos-pyqt5-no_cov: exit 101 (0.35 seconds) /Users/grzegorzbokota/Documents/Projekty/napari> python -I -m uv pip install --force-reinstall --no-deps 'napari @ /tmp/.tox/.tmp/package/7/napari-0.5.0a2.dev578+g17b00de2.tar.gz' pid=3499

Czaki avatar Feb 16 '24 16:02 Czaki

Related to #313

zanieb avatar Feb 16 '24 16:02 zanieb

tox devs published owns tox-uv plugin https://github.com/tox-dev/tox-uv (but it crashes tox in my case)

Czaki avatar Feb 16 '24 17:02 Czaki

@charliermarsh now that https://pypi.org/project/tox-uv/ is launched, I think we can close this. Unless you want to document it somewhere, the advice to use that. sdists seem to still be troublesome occasionally, but otherwise work well.

gaborbernat avatar Feb 16 '24 20:02 gaborbernat

Closing as tox-uv now exists!

charliermarsh avatar Mar 04 '24 01:03 charliermarsh