From e43cca855f64e278de2994a551d0521bd87a1228 Mon Sep 17 00:00:00 2001
From: Jeff Dickey <216188+jdx@users.noreply.github.com>
Date: Sun, 13 Oct 2024 16:36:29 -0500
Subject: [PATCH] feat: allow passing arbitrary args to pipx/uvx
Fixes #2722
---
docs/dev-tools/backends/pipx.md | 27 ++++++++++++++-------------
docs/lang/node.md | 3 ---
schema/mise.json | 9 +++++++++
settings.toml | 17 ++++++++++++++++-
src/backend/pipx.rs | 18 ++++++++++++------
5 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/docs/dev-tools/backends/pipx.md b/docs/dev-tools/backends/pipx.md
index 7e3ecae49d..714e5b49cb 100644
--- a/docs/dev-tools/backends/pipx.md
+++ b/docs/dev-tools/backends/pipx.md
@@ -53,22 +53,23 @@ The version will be set in `~/.config/mise/config.toml` with the following forma
Other syntax may work but is unsupported and untested.
-## Configuration
+## Settings
Set these with `mise settings set [VARIABLE] [VALUE]` or by setting the environment variable listed.
-### `pipx_uvx`
+
+
-- Type: `bool`
-- Env: `MISE_PIPX_UVX`
-- Default: `false`
+## Tool Options
-If true, mise will use `uvx` instead of `pipx` if
-[`uv`](https://docs.astral.sh/uv/) is installed and on PATH.
-This makes installing CLIs _much_ faster by using `uv` as the package manager.
+The following [tool-options](/dev-tools/#tool-options) are available for the `pipx` backend:
-You can install it with mise:
-
-```sh
-mise use -g uv
-```
+| Option | Description | Example |
+| ----------- | ------------------------------------------------------ | --------------------------------------------------------------------------- |
+| `extras` | Install additional components | `"pipx:harlequin" = { version = "latest", extras = "postgres,s3" } |
+| `pipx_args` | Additional arguments to pass to `pipx` when installing | `"pipx:black" = { version = "latest", pipx_args = "--preinstall" }` |
+| `uvx_args` | Additional arguments to pass to `uvx` when installing | `"pipx:ansible-core" = { version = "latest", uvx_args = "--with ansible" }` |
diff --git a/docs/lang/node.md b/docs/lang/node.md
index 2e4fa455f1..b14a505de1 100644
--- a/docs/lang/node.md
+++ b/docs/lang/node.md
@@ -27,11 +27,8 @@ required system dependencies.
-
### Environment Variables
diff --git a/schema/mise.json b/schema/mise.json
index a8aaca3e0c..cc3fd9fb34 100644
--- a/schema/mise.json
+++ b/schema/mise.json
@@ -297,6 +297,15 @@
"description": "Default to pinning versions when running `mise use` in mise.toml files.",
"type": "boolean"
},
+ "pipx": {
+ "additionalProperties": false,
+ "properties": {
+ "uvx": {
+ "description": "Use uvx instead of pipx if uv is installed and on PATH.",
+ "type": "boolean"
+ }
+ }
+ },
"pipx_uvx": {
"description": "Use uvx instead of pipx if uv is installed and on PATH.",
"type": "boolean"
diff --git a/settings.toml b/settings.toml
index 1023e9d49a..898931515d 100644
--- a/settings.toml
+++ b/settings.toml
@@ -348,10 +348,25 @@ This sets `--pin` by default when running `mise use` in mise.toml files. This ca
passing `--fuzzy` on the command line.
"""
+[pipx.uvx]
+type = "Bool"
+description = "Use uvx instead of pipx if uv is installed and on PATH."
+docs = """
+If true, mise will use `uvx` instead of `pipx` if
+[`uv`](https://docs.astral.sh/uv/) is installed and on PATH.
+This makes installing CLIs _much_ faster by using `uv` as the package manager.
+
+You can install it with mise:
+
+```sh
+mise use -g uv
+```
+"""
+
[pipx_uvx]
-env = "MISE_PIPX_UVX"
type = "Bool"
description = "Use uvx instead of pipx if uv is installed and on PATH."
+hide = true
[plugin_autoupdate_last_check_duration]
env = "MISE_PLUGIN_AUTOUPDATE_LAST_CHECK_DURATION"
diff --git a/src/backend/pipx.rs b/src/backend/pipx.rs
index 7fe0537f02..64bd8335a3 100644
--- a/src/backend/pipx.rs
+++ b/src/backend/pipx.rs
@@ -85,7 +85,7 @@ impl Backend for PIPXBackend {
.pipx_request(&ctx.tv.version, &ctx.tv.request.options());
if settings.pipx_uvx {
- CmdLineRunner::new("uv")
+ let mut cmd = CmdLineRunner::new("uv")
.arg("tool")
.arg("install")
.arg(pipx_request)
@@ -96,10 +96,13 @@ impl Backend for PIPXBackend {
.prepend_path(ctx.ts.list_paths())?
// Prepend install path so pipx doesn't issue a warning about missing path
.prepend_path(vec![ctx.tv.install_path().join("bin")])?
- .prepend_path(self.dependency_toolset()?.list_paths())?
- .execute()?;
+ .prepend_path(self.dependency_toolset()?.list_paths())?;
+ if let Some(args) = ctx.tv.request.options().get("uvx_args") {
+ cmd = cmd.args(shell_words::split(args)?);
+ }
+ cmd.execute()?;
} else {
- CmdLineRunner::new("pipx")
+ let mut cmd = CmdLineRunner::new("pipx")
.arg("install")
.arg(pipx_request)
.with_pr(ctx.pr.as_ref())
@@ -109,8 +112,11 @@ impl Backend for PIPXBackend {
.prepend_path(ctx.ts.list_paths())?
// Prepend install path so pipx doesn't issue a warning about missing path
.prepend_path(vec![ctx.tv.install_path().join("bin")])?
- .prepend_path(self.dependency_toolset()?.list_paths())?
- .execute()?;
+ .prepend_path(self.dependency_toolset()?.list_paths())?;
+ if let Some(args) = ctx.tv.request.options().get("pipx_args") {
+ cmd = cmd.args(shell_words::split(args)?);
+ }
+ cmd.execute()?;
}
Ok(())
}