tox-dev / tox-uv

Use https://github.com/astral-sh/uv with tox
MIT License
66 stars 14 forks source link

Add uv_resolution as testenv parameter #39

Closed Stealthii closed 6 months ago

Stealthii commented 6 months ago

uv supports defining a custom resolution strategy, defaulting to 'highest', and allowing 'lowest' or 'lowest-direct' at the time of writing, which provides an alternative to package constraints enabling lowest direct or transitive dependencies to be installed.

This change provides a new uv_resolution configuration option for test environments, which if defined will apply the --resolution option to uv to enable this behavior.

Implements #28.

Stealthii commented 6 months ago

Example testenv configuration using this strategy over frozen dependencies:

diff --git a/tox.ini b/tox.ini
index b55b1b9..9b43d88 100644
--- a/tox.ini
+++ b/tox.ini
@@ -35,21 +35,4 @@ commands =
     pre-commit run --all-files --show-diff-on-failure

 [testenv:py38-mindeps]
-deps =
-    anyio==4
-    asyncer==0.0.4
-    asyncssh==2.13.1
-constrain_package_deps = true
-use_frozen_constraints = true
+uv_resolution = lowest-direct
py38-mindeps: install_package_deps> /Users/dporter/.pyenv/versions/3.11.8/bin/uv pip install --resolution lowest-direct 'anyio<5,>=4' 'asyncer<1,>=0.0.4' 'asyncssh<3,>=2.13.1'
py38-mindeps: install_package> /Users/dporter/.pyenv/versions/3.11.8/bin/uv pip install --resolution lowest-direct --reinstall --no-deps example@example-3.14.0.dev55+gd9e2194.d20240313-py3-none-any.whl
gaborbernat commented 6 months ago

Seems you've angered the type gods 🤔

Stealthii commented 6 months ago

Updating the tests here shortly to validate the new checker.