Open kdeldycke opened 3 months ago
Thank you for writing it up in this detail! I agree that we likely want to support --override
in uv run
(CC @zanieb - I think could have the same semantics as --with
). For now, we support tool.uv.override-dependencies
in pyproject.toml
, but we plan for adding a proper workflow around trying unreleased upstream dependencies.
Thanks @konstin for validating my use-case!
Indeed, [tool.uv.override-dependencies]
in pyproject.toml
does the trick. So I implemented a workaround here:
And here is the proof in workflow execution: https://github.com/kdeldycke/click-extra/actions/runs/9806741540/job/27079121955#step:9:18
What would the target of --override
be? A dependency? A file?
I'd say --override
is a multiple use argument that takes a PEP 508 requirement each time, since the file case is covered by tool.uv.override-dependencies
; at least i'm not aware of any cases of shared override files.
What would the target of
--override
be? A dependency? A file?
Nothing of substance to say but I'll be happy either way! :)
I don't think we need this for the release. --with
functions roughly as an override in uv run
. We should support this eventually though.
I can confirm that --with
does the trick with latest uv
:
$ uv --version
uv 0.2.28 (3a8535370 2024-07-23)
$ uv run --with "git+https://github.com/pallets/click.git@main" pytest
warning: `uv run` is experimental and may change without warning
Resolved 76 packages in 7ms
Audited 19 packages in 0.08ms
Updated https://github.com/pallets/click.git (14f735c)
Resolved 1 package in 1.83s
Installed 1 package in 1ms
+ click==8.2.0.dev0 (from git+https://github.com/pallets/click.git@14f735cf59618941cf2930e633eb77651b1dc7cb)
======= test session starts =======
(...)
Using the latest
uv
:Use-case
I have a test workflow for my
click-extra
project which boils down to:Everything's good as it is.
But now I want to override some of the default dependencies specified in
pyproject.toml
. My use-case is to test unreleased upstream dependencies, so I can anticipate upcoming breaking changes.What I used to do with Poetry was to locally add these new dependencies as-is:
Migrating to
uv
, my new workflow looks like this:But this doesn't work as I expected. As soon as I call
uv run pytest
, the locally installed Click is discarded, and replaced by the canonical requirement frompyproject.toml
:See how I installed the
click==8.2.0.dev0
version I am looking for:And then have
uv run pytest
re-installing backclick==8.1.7
:--override
workaroundDigging into
uv
help, I stumble upon the--override
option, which seems to be the way to do what I want.So I now have:
And using it ends up with the right dependencies:
Which seems to do the trick. But again,
uv run
is reverting my override:--override
not supported byuv run
So maybe I need to use
--override
onuv run
. But it is not supported:Should we requalify this ticket into a feature request to have
--override
supported by therun
subcommand?New
--no-upgrade
option foruv run
?Another alternative is maybe to have a
--no-upgrade
option onuv run
to tell it to not make any changes to the currently installed dependencies.That might be the opposite of the existing
-U/--upgrade
parameter: