Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task runner plugin system #10211

Closed
rmorshea opened this issue Dec 28, 2024 · 5 comments
Closed

Task runner plugin system #10211

rmorshea opened this issue Dec 28, 2024 · 5 comments

Comments

@rmorshea
Copy link

rmorshea commented Dec 28, 2024

In my projects that use uv I've developed a pattern (which I've encoded in a template repo) where I define a script called dev.py that uses click to define a CLI and automate common tasks (e.g. running tests, building docs and linting). With that in mind it would be nice if it were possible to define a "default script" so that, instead of typing uv run dev.py ..., I could avoid typing dev.py each time and use a shorter command a la yarn run or npm run which inherit commands from the scripts section of package.json. Since uv run wouldn't be suitable for this due to the fact that positional arguments would be confused with executables, an alternative command like uv do ... would be necessary. A hypothetical configuration could look something like:

[tool.uv.do]
command = "uv run dev.py"

I understand this might be considered relatively niche, however I could imagine a feature like this negating the need for UV to develop it's own system for defining and executing "user scripts" as other package managers in the Python space have (e.g. Hatch's and PDM's approaches). Instead, UV could defer to existing tools in the Python ecosystem for this like Nox or Invoke.

@FishAlchemist
Copy link
Contributor

Although the expected format is different, does this issue(#5903) function as you expected?

@zanieb
Copy link
Member

zanieb commented Dec 28, 2024

Interesting, this sounds like an implementation of #5903 that just invokes a third-party tool? Sort of a plugin system?

@rmorshea
Copy link
Author

rmorshea commented Dec 28, 2024

@zanieb I think it could function that way. Put another way, I'm proposing that UV provide a command for projects to alias in whatever way they might want.

Taking the initial taskipy example from #5903 you could configure:

[dependency-groups]
dev = ["taskipy"]

[tool.uv.do]
command = "uv run task"

[tool.taskipy.tasks]
hello = "echo Hello from taskipy!"

Any then run:

uv do hello

I see two main advantages of this approach has over #5903:

  • If you choose to use another tool to manage your scripts you don't need to ensure you've copied them both under [tool.uv.tasks] and that tool's configuration location of choice. To me, having a bunch of "tasks" which look like uv run uvx --from=rust-just just <the-task> seems redundant and annoying to maintain. Instead, under this proposal you could simply configure:

    [tool.uv.do]
    command = "uv run uvx --from=rust-just just"
  • As mentioned above, UV doesn't need to develop and maintain a task running system that will inevitably grow in scope and complexity. While choosing not to provide a task runner out of the box might not conform to people's expectations, I think it could be pretty easily addressed with a short and easily discoverable section of documentation that provides a recommended solution for people to copy-paste into their projects.

@rmorshea
Copy link
Author

One downside of this proposal vs #5903 is that new contributors to a project that uses UV won't always be able to look for the same tool.uv.tasks configuration to find the set of common commands they might want to run.

@rmorshea rmorshea changed the title Consider option to define a "default script" Task runner plugin system Jan 2, 2025
@rmorshea
Copy link
Author

rmorshea commented Jan 2, 2025

@zanieb would you recommend closing this issue in favor of #5903?

@zanieb zanieb closed this as completed Jan 2, 2025
@zanieb zanieb closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants