Skip to content

Commit

Permalink
feat: allow passing arbitrary args to pipx/uvx
Browse files Browse the repository at this point in the history
Fixes #2722
  • Loading branch information
jdx committed Oct 13, 2024
1 parent 614ac40 commit e43cca8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 23 deletions.
27 changes: 14 additions & 13 deletions docs/dev-tools/backends/pipx.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<script setup>
import { data } from '/settings.data.ts';
import Setting from '/components/setting.vue';
const settings = data.find(s => s.key === 'node').settings;
</script>
<Setting v-for="setting in settings" :setting="setting" :key="setting.key" :level="3" />

- 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" }` |
3 changes: 0 additions & 3 deletions docs/lang/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ required system dependencies.
<script setup>
import { data } from '/settings.data.ts';
import Setting from '/components/setting.vue';

const settings = data.find(s => s.key === 'node').settings;

</script>

<Setting v-for="setting in settings" :setting="setting" :key="setting.key" :level="3" />

### Environment Variables
Expand Down
9 changes: 9 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 16 additions & 1 deletion settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 12 additions & 6 deletions src/backend/pipx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand All @@ -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(())
}
Expand Down

0 comments on commit e43cca8

Please sign in to comment.