Closed ashbywinch closed 3 weeks ago
I think the problem you're running into here is that uvx
runs in an environment isolated from your project. Can you try uv run pytest
instead? Or even uv run --with pytest pytest
if it's not part of your project environment?
Some documentation on this at https://docs.astral.sh/uv/concepts/tools/#relationship-to-uv-run
We may be able to improve the documentation though, if you have any questions.
Yes, that's fixed it! Thanks 👍 I think it might have helped if this page here: https://docs.astral.sh/uv/guides/tools/ had a section right at the top clarifying why one would or wouldn't want to run a tool without installing, and pointing to the section on how to run a tool WITH installing (or without installing but with plugins, which is mentioned, but much further down the page). The info I needed was all there, but I didn't realise it would be relevant when I first read it, and I didn't know where to look for solutions once I ran into the problem.
Addressing that with https://github.com/astral-sh/uv/pull/6454 — let me know if that's not helpful.
That looks spot on 👍
I tried to migrate a project to uv, but pytest could no longer find its plugins pytest-cov and pytest-testmon.
On investigation it seems that pytest uses Pluggy to load the plugins, and Pluggy uses importlib.metadata.distributions() to identify and load installed packages that have entrypoints matching its naming convention (see Pluggy source)
I made an empty project with "uv init", added dependencies [ "pytest", "pytest-cov", "pytest-testmon" ], ran "uv sync" successfully (I can see the installed files in .venv/lib/site-packages) and ran the following code
Under my regular project this code prints (among other things):
Under my uv test project those modules/endpoints are not in the list, even though they have been successfully installed.
and this is on Win11.