Skip to content

Conversation

@sgaist
Copy link
Contributor

@sgaist sgaist commented Oct 18, 2025

Add a tox configuration that runs tests using uv and its own provided python versions.

This configuration uses the lowest-direct resolution logic as well as only use uv manager python version.

Fixes #13177

Acceptance test needed to be adjusted as
test_stop_iteration_runtest_protocol triggers
a different error message that seems to map to
PEP-0479 when using a uv provided python environment.
Coverage is already done in the standard tests.
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this @sgaist! Please see my comments/questions.

Comment on lines 48 to 65
dependencies = [
"colorama>=0.4; sys_platform=='win32'",
"exceptiongroup>=1; python_version<'3.11'",
"iniconfig>=1.0.1",
"exceptiongroup>=1.1; python_version<'3.11'",
"iniconfig>=2",
"packaging>=22",
"pluggy>=1.5,<2",
"pygments>=2.7.2",
"pygments>=2.14",
"tomli>=1; python_version<'3.11'",
]
optional-dependencies.dev = [
"argcomplete",
"attrs>=19.2",
"hypothesis>=3.56",
"mock",
"requests",
"setuptools",
"xmlschema",
"argcomplete>=3.5",
"attrs>=21",
"hypothesis>=5",
"mock>=5",
"requests>=2.26",
"setuptools>=80",
"xmlschema>=3",
]
Copy link
Member

@bluetech bluetech Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes needed? Is it from testing with lowest-direct?

For the dev deps I don't mind much, perhaps except for attrs and mock which we use for testing pytest integration features so being able to test with older versions is somewhat useful.

But for the runtime dependencies, how did you determine the lower bounds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, lowest-direct showed that the oldest version it could get were sometimes using obsolete APIs.

My first tries were to slowly bump the versions of the dependencies that were posing problems. Since some of them were a bit less cooperative, I went to check which years the packages had releases around Python 3.10 initial release. So, in the absolute, I would say it's worth revisiting them to ensure I did not miss something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your method sounds good to me (cc @RonnyPfannschmidt on iniconfig).

Could you add a packaging changelog entry detailing the changes to the lower bounds of exceptiongroup, iniconfig and pygments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done but I may have been a bit short

@@ -0,0 +1,125 @@
name: test uv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would all-around be better if we could integrate this into the main workflow file, just controlling it with a matrix option (environment variables).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I got it correctly in the main test workflow.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 22, 2025
@bluetech bluetech mentioned this pull request Oct 23, 2025
@bluetech
Copy link
Member

@sgaist Thanks for the update. To clarify, I'd like the tox and CI to be in the same file/job. I'm thinking something like this:

diff --git i/.github/workflows/test.yml w/.github/workflows/test.yml
index 1c5eb584f..481fdad20 100644
--- i/.github/workflows/test.yml
+++ w/.github/workflows/test.yml
@@ -56,7 +56,7 @@ jobs:
       fail-fast: false
       matrix:
         name: [
-          "windows-py310-unittest-asynctest",
+          "windows-py310-unittest-asynctest-lowestdirect-onlymanaged",
           "windows-py310-unittest-twisted24",
           "windows-py310-unittest-twisted25",
           "windows-py310-pluggy",
@@ -90,11 +90,12 @@ jobs:
 
         include:
           # Use separate jobs for different unittest flavors (twisted, asynctest) to ensure proper coverage.
-          - name: "windows-py310-unittest-asynctest"
+          - name: "windows-py310-unittest-asynctest-lowestdirect-onlymanaged",
             python: "3.10"
             os: windows-latest
-            tox_env: "py310-asynctest"
+            tox_env: "py310-asynctest-lowestdirect-onlymanaged"
             use_coverage: true
+            use_uv: true
 
           - name: "windows-py310-unittest-twisted24"
             python: "3.10"
@@ -273,6 +274,11 @@ jobs:
         python -m pip install --upgrade pip
         pip install tox coverage
 
+    - name: Set up uv
+      if: "matrix.use_uv"
+      shell: bash
+      run: pip install tox-uv
+
     - name: Test without coverage
       if: "! matrix.use_coverage"
       shell: bash
diff --git i/tox.ini w/tox.ini
index fa86c9c44..cf5f7fef0 100644
--- i/tox.ini
+++ w/tox.ini
@@ -39,6 +39,8 @@ description =
     twisted25: against the unit test extras with twisted 25.0 or later
     asynctest: against the unit test extras with asynctest
     xdist: with pytest in parallel mode
+    lowestdirect: using lowest-direct resolution when running with uv
+    onlymanaged: using only managed python running with uv
     under `{basepython}`
     doctesting: including doctests
 commands =
@@ -80,6 +82,10 @@ setenv =
     lsof: _PYTEST_TOX_POSARGS_LSOF=--lsof
 
     xdist: _PYTEST_TOX_POSARGS_XDIST=-n auto
+uv_resolution =
+    lowestdirect: lowest-direct
+uv_python_preference =
+    onlymanaged: only-managed
 extras = dev
 deps =
     doctesting: PyYAML

I tried it, unfortunately I hit some problem with tox-uv: tox-dev/tox-uv#260
Maybe there's a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an uv-managed Python to CI

2 participants