Repository navigation
Description
For those of us migrating over from Rye, one of its nice features is the built-in task runner using rye run and [tool.rye.scripts]. For example:
[tool.rye.scripts]
hello = "echo Hello from Rye!"
$ rye run hello
Hello from Rye!
It could have some more features - here is a selection of feature requests from the community:
- Allow shell expansion/interpolation in rye run command rye#695
- Allow to define local variable in rye scripts rye#652
- ✨ Allow passing cwd in
tool.rye.scriptsrye#930 - Support for pre-/post-hooks in Rye custom scripts rye#1243
A lot of these requested features are things that other 3rd party tools currently offer. I thought it might be useful to highlight a few other tools here, in particular because they also integrate with the pyproject.toml ecosystem and can be used with uv today.
-
Poe the Poet
https://github.com/nat-n/poethepoet
uv add --dev poethepoet[tool.poe.tasks] hello = "echo Hello from poe!"$ uv run poe hello Poe => echo Hello from 'poe!' Hello from poe! -
taskipy
https://github.com/taskipy/taskipy
uv add --dev taskipy[tool.taskipy.tasks] hello = "echo Hello from taskipy!"$ uv run task hello Hello from taskipy!
Perhaps these can serve as some inspiration for a future uv run task runner and also in the meantime offer a solution for people coming over from Rye looking for a way to run tasks.
Activity
chrisrodrigue commentedon Aug 8, 2024
Relevant comment from another issue: #5632 (comment)
chrisrodrigue commentedon Aug 8, 2024
PDM supports this: https://pdm-project.org/latest/usage/scripts/
charliermarsh commentedon Aug 9, 2024
Yeah we plan to support something like this! We haven't spent time on the design yet.
nikhilweee commentedon Aug 9, 2024
The pyproject standard already supports
[project.scripts], so uv may not need to use its own table.https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts
charliermarsh commentedon Aug 9, 2024
[project.scripts]is a little different -- that's used to expose specific Python functions as executable scripts, and we do support that already.chrisrodrigue commentedon Aug 9, 2024
Perhaps naming this section
tool.uv.tasksortool.uv.aliasescould help disambiguate that.nikhilweee commentedon Aug 10, 2024
Or maybe
[tool.uv.run]to be consistent with the commanduv run. Or we could even think about[tool.uv.commands].I'm not a big fan of
[tool.uv.scripts]since it conflicts with[project.scripts]and I myself got confused before.cdwilson commentedon Aug 23, 2024
This is the main thing I missed coming from hatch: https://hatch.pypa.io/dev/config/environment/overview/#scripts
chrisrodrigue commentedon Aug 23, 2024
+1 to @nikhilweee suggestions. I think “command” reflects the intent/concept.
Hatch has an “environment” concept and supports running commands namespaced to an environment like so
where “test” is a user-defined environment (with a dependency group) and “cov” is a user-defined command for that environment.
I would be curious to hear the use cases of nesting dependency groups and commands into “environments” like this rather than defining them at the top-level (i.e.
[tool.uv.commands]/[tool.uv.dev-dependencies]).pietroppeter commentedon Aug 28, 2024
since it has not been mentioned yet, adding as a possible inspiration for design of tasks also pixi: https://pixi.sh/latest/features/advanced_tasks/
metaist commentedon Aug 28, 2024
I happen to be writing a cross-project task runner that supports a bunch of formats (e.g. rye, pdm, package.json, Cargo.toml; even uv's workspace config).
For what it's worth, almost all python runners use
tool.<name>.scriptsfor task config (presumably inspired by npm'spackage.jsonformat), so it's somewhat of an easier upgrade path for people coming from other tools.https://github.com/metaist/ds
inoa-jboliveira commentedon Sep 8, 2024
Also related to this thread, I wish uvx was
uv runinstead ofuv tool runwhen inside a project.uv tool runseems like something you would do to play with a tool, like ruff. But then you will eventuallyuv add ruff --devand forever keep writinguv run ruff checkinstead ofuvx ruff checkwhich won't respect the locked version and will be in different virtualenv. It also means the tool could be running on a different Python (does not apply to ruff, but any other python lib) and all sorts of weird stuff can happen.I know
uv run stuffis still short, but it could be 4 keystrokes shorter.Regarding
uv runbeing a task runner it means people will type it waaaaay more often thanuv tool run.I would appreciate a dedicated command like
uvr256 remaining items
roman-k-kaimakov commentedon Apr 21, 2026
EED85 commentedon Jun 11, 2026
Hi all,
Currently, upgrading multiple specific packages requires repeating the flag:
uv sync --upgrade-package marimo --upgrade-package polars --upgrade-package hvplotIt would be great to support defining aliase so it could be shortened to
uv upgrade-packages marimo polars hvplot(for example)christiansegercrantz commentedon Jun 11, 2026
This feels like a separate topic, not something a
uv runwould be used for. This should be a built-in feature if it would be implementedtback commentedon Jun 11, 2026
krzkaczor commentedon Aug 31, 2026
For those who cares (especially while working with workspaces), uv-tasks does most of the needed things:
pyproject.toml:It works in a way that does single
uv sync --all-packagesbefore executing scripts so there might be some collisions between scripts. Watch out for this if you have name collisions across your workspace.I am surprised that uv doesn't come with something built-in and I would be more than happy to champion this. At this stage it's quite simple but it works well for my needs. Ohh and I've vibeslopped it in rust so it's blazingly fast ;)
ksamuel commentedon Sep 1, 2026
Please don't spam this thread with your grab for attention.
The whole point of this is to have a well designed, high quality and strongly integrated solution. If you are going to offer a low-effort, vibecoded, half-baked workaround that doesn't even bring anything on top of
justand shows you clearly haven't read any part of the previous discussion, you don't bring anything to the table.docs: environment reference; poe task runner for local commands
Enzo-Agosta commentedon Sep 25, 2026
I'd like to try and recenter the discussion if we can. Everyone mostly agreed on @lucabello's alias approach a while ago, and for good reason I think. Below is what I think the design should look like, to try and move the discussion further.
AI Note: GPT and Opus helped me in refining my arguments and they wrote the draft of this comment. But I stand behind every word as if they were mine, and I rewrote most of the prose myself.
The one rule I think
uv taskshould follow religiously is:The design I personally envision looks something like
In this situation:
uv task lintrunsuv run ruff checkuv task docsrunsuv run --group docs sphinx-build ...uv task --locked ciruns the four tasks in order, each one with--lockedSince
tasksis really just arguments foruv run, we inherit all of the limitations but also all of the benefits ofuv run. We don't need to design anything new for dependency groups, env files,--frozenor workspaces.Whatever
uv runsupports,uv taskssupports it, and conflicting options fail the same way they already do. Tasks are argument lists rather than strings so there is no command-line parsing to specify; that costs some punctuation, but tasks are written once and run many times.To go through the rest of the semantics:
uv taskwith no name lists the tasks and sequences. It never runs anything, so it's always safe to type in an unfamiliar repo. (This is also why I'd skip a default task, see here)uv taskis its own command, so task names never shadow executables inuv run.uv task test -k login. Sequences reject extra arguments rather than guessing which step should get them.uv runwould. I would argue for stopping the sequence on the first failure and returning that exit code.ci = { sequence = [...] }is something I'm fully fine with and would allow for adding help docs or more options without much trouble in the future.)--package, with no fallback to the workspace root.If we want this to actually be something maintainable and implementable I would explicitly keep all the below out of scope:
$VARS,&&, or pipes. Once any of that is supported, uv has to define a shell dialect and make it behave the same on Windows.deno taskalready did it, and they had to build their own shell to make it truly portable. I don't think that's a burden uv should take on, at least not now.On @zanieb's question about what uv adds over re-implementing Poe:
uv formatrather than against them.On the standards discussions: a scope this small should be small and easy enough to map onto whatever gets standardized later, since it can only grow, not conflict.
The one thing I'd like to hear from maintainers would be regarding the strict "a task is exactly a
uv runinvocation" rule I propose. Is this a constraint you would be willing to accept, and are thereuv runoptions you wouldn't want reachable from a task definition?mfisher87 commentedon Sep 29, 2026
What does this look like to you? Validating the command and throwing an error if e.g.
&&is present? Or allow the user to use whatever they want and if they run it on an incompatible shell that's their problem?AI0867 commentedon Sep 30, 2026
I'm guessing, that invoking
uv task foo bar baz, whentool.uv.tasks.foo = ["something", "&&", "else"],will run something equivalent to
uv run something "&&" else bar baz, or somewhat more accurately,execve(UV, ["uv", "run", "something", "&&", "else", "bar", "baz"]), with no shell being involved. If those args mean something to the "something" that is getting run, great. If not, that's a problem for who defined the task or passed the args.If you want shell support, you can define a task
tool.uv.tasks.bash = ["bash"]or something like that, but then it's on you to make sure bash is installed.Enzo-Agosta commentedon Sep 30, 2026
That sums it up nicely, @AI0867. TOML gives us an array of strings, which become arguments to
uv run. Nothing interprets them as shell syntax.&&,$VARS, and glob patterns are passed literally to the executable. That’s what I mean by no shell.There would be no validation for shell syntax either. As you said, whether those arguments mean anything is up to the program receiving them.
Someone could explicitly invoke a shell, just as they can with
uv runtoday. But I’d be reluctant to document or encourage that as an escape hatch. My concern is that users would reasonably see a task defined under[tool.uv.tasks]as something uv supports, then report problems to uv when the shell is missing, its syntax differs across platforms, or paths behave differently.Even if we document where uv’s responsibility ends, those reports still create work for maintainers. Part of the argument for this proposal is its limited scope and maintenance burden. Encouraging shell invocation weakens that argument, so I’d keep the feature and its recommended usage focused on passing literal arguments to executables.
refs #23 Medir uv en local
refs #23 Medir uv en local