Open hynek opened 3 weeks ago
I mean we can do it by hand or install_commands.
@hynek As a stopgap measure, could you please share how to do this with install_command
? :)
Was unable to figure out a workaround
I cannot. I was/am on my phone and only guessing; sorry. :)
I am not against this. Actually, I would like to see support for this. However, I did not get any chance to look into this release and how it works and what is the feature gap. I might get to it in a month or so, but don't expect anything anytime soon. If someone else has time and can put together a proposal in the meantime, That would be much appreciated.
I think it'd be worth waiting for https://github.com/astral-sh/uv/issues/5632 to be actioned, adding uv tools to a project / dependency groups to the lock file. At the moment, the uv lock file doesn't include any developer tool dependencies
Might have to wait for this https://github.com/astral-sh/uv/issues/5229 as well?
At the moment, uv sync
installs into the environment at $PROJECT_ROOT/.venv
- not into the currently active environment (i.e. the tox env).
JFTR UV_PROJECT_ENVIRONMENT that allows to point at venvs has shipped
also JFTR, since I looked into it closer: https://github.com/astral-sh/uv/issues/5632 shouldn't be a blocker since it's strictly an add-on.
It's about having dependency groups within --dev
, currently there's only one. But you can already have optional dependencies like now and they're locked just fine.
At the moment, the uv lock file doesn't include any developer tool dependencies
That also means that this isn't accurate (anymore?). It locks dev deps just fine, you just can have one group of them.
I use the following configuration to use the uv.lock
file:
[testenv]
description = run the tests with pytest
set_env =
UV_PROJECT_ENVIRONMENT={envdir}
commands_pre =
uv sync --python {env_python} --locked --inexact
commands = ...
And I use uvx --with tox-uv tox ...
to run tox. :slightly_smiling_face:
Cool, something like that I had in mind when I guessed it could be faked for now!
But you probably want --frozen
, not --locked
because the latter errors out the moment the lock file is out of date which usually is not what you want. The whole point is to have stable builds and handle updates safely.
Does commands_pre
run before the package itself is installed? Because then you can save some nanoseconds by passing --no-install-project
, too. ;)
Oh and N.B. that uv sync
installs all dev deps if you don't pass --no-dev
. I'm not sure if you can receive extras in commands_pre
? Because getting them installed later using uv pip
won't respect the lock file.
But you probably want
--frozen
, not--locked
because the latter errors out the moment the lock file is out of date which usually is not what you want. The whole point is to have stable builds and handle updates safely.
I prefer the error when the lockfile is out of date, but --frozen
is also a valid option. :slightly_smiling_face:
Does
commands_pre
run before the package itself is installed? Because then you can save some nanoseconds by passing--no-install-project
, too. ;)
I also use
[testenv]
package = skip
[tool.uv]
package = false
(in pyproject.toml)
So installing the project is of no concern to me.
Oh and N.B. that
uv sync
installs all dev deps if you don't pass--no-dev
. I'm not sure if you can receive extras incommands_pre
? Because getting them installed later usinguv pip
won't respect the lock file.
I do want the uv declared dev dependencies.
uv sync
supports the --extra
option (which can be supplied multiple times).
{extras}
in tox is a list, so it won't work out of the box, but maybe it's possible to do some massaging while substituting?
What's the problem this feature will solve?
Uv added a cross-platform lock format in 0.3.0. I can see this to become a standard for packages to keep CI stable.
Describe the solution you'd like
Given how early it is on uv’s and tox-uv’s life, I could imagine tox-uv to detect the lock file automatically and instead of doing
uv pip install
it would runuv sync
?It [cs]ould be configurable of course, but this would seem like a great step improvement on general DX.
Alternative Solutions
I mean we can do it by hand or install_commands.
Additional context
https://docs.astral.sh/uv/concepts/projects/