Skip to content

Commit 9c28f18

Browse files
committed
Support --with-editable in uv tool install
1 parent 2f6fa08 commit 9c28f18

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,6 +3514,10 @@ pub struct ToolInstallArgs {
35143514
#[arg(short, long)]
35153515
pub editable: bool,
35163516

3517+
/// Include the given packages as editables.
3518+
#[arg(long, value_delimiter = ',')]
3519+
pub with_editable: Vec<String>,
3520+
35173521
/// The package to install commands from.
35183522
///
35193523
/// This option is provided for parity with `uv tool run`, but is redundant with `package`.

crates/uv/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
922922
.with
923923
.into_iter()
924924
.map(RequirementsSource::from_with_package)
925+
.chain(
926+
args.with_editable
927+
.into_iter()
928+
.map(RequirementsSource::Editable),
929+
)
925930
.chain(
926931
args.with_requirements
927932
.into_iter()

crates/uv/src/settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ pub(crate) struct ToolInstallSettings {
389389
pub(crate) from: Option<String>,
390390
pub(crate) with: Vec<String>,
391391
pub(crate) with_requirements: Vec<PathBuf>,
392+
pub(crate) with_editable: Vec<String>,
392393
pub(crate) python: Option<String>,
393394
pub(crate) refresh: Refresh,
394395
pub(crate) options: ResolverInstallerOptions,
@@ -406,6 +407,7 @@ impl ToolInstallSettings {
406407
editable,
407408
from,
408409
with,
410+
with_editable,
409411
with_requirements,
410412
installer,
411413
force,
@@ -427,6 +429,7 @@ impl ToolInstallSettings {
427429
package,
428430
from,
429431
with,
432+
with_editable,
430433
with_requirements: with_requirements
431434
.into_iter()
432435
.filter_map(Maybe::into_option)

crates/uv/tests/it/show_settings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,7 @@ fn resolve_tool() -> anyhow::Result<()> {
26062606
from: None,
26072607
with: [],
26082608
with_requirements: [],
2609+
with_editable: [],
26092610
python: None,
26102611
refresh: None(
26112612
Timestamp(

crates/uv/tests/it/tool_install.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use predicates::prelude::predicate;
1111

1212
use uv_static::EnvVars;
1313

14-
use crate::common::{uv_snapshot, TestContext};
14+
use crate::common::{copy_dir_all, uv_snapshot, TestContext};
1515

1616
#[test]
1717
fn tool_install() {
@@ -171,6 +171,49 @@ fn tool_install() {
171171
});
172172
}
173173

174+
#[test]
175+
fn tool_install_with_editable() -> anyhow::Result<()> {
176+
let context = TestContext::new("3.12").with_filtered_counts();
177+
let tool_dir = context.temp_dir.child("tools");
178+
let bin_dir = context.temp_dir.child("bin");
179+
let anyio_local = context.temp_dir.child("src").child("anyio_local");
180+
copy_dir_all(
181+
context.workspace_root.join("scripts/packages/anyio_local"),
182+
&anyio_local,
183+
)?;
184+
185+
uv_snapshot!(context.filters(), context.tool_install()
186+
.arg("--with-editable")
187+
.arg("./src/anyio_local")
188+
.arg("--with")
189+
.arg("iniconfig")
190+
.arg("flask")
191+
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
192+
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str())
193+
.env(EnvVars::PATH, bin_dir.as_os_str()), @r###"
194+
success: true
195+
exit_code: 0
196+
----- stdout -----
197+
198+
----- stderr -----
199+
Resolved [N] packages in [TIME]
200+
Prepared [N] packages in [TIME]
201+
Installed [N] packages in [TIME]
202+
+ anyio==4.3.0+foo (from file://[TEMP_DIR]/src/anyio_local)
203+
+ blinker==1.7.0
204+
+ click==8.1.7
205+
+ flask==3.0.2
206+
+ iniconfig==2.0.0
207+
+ itsdangerous==2.1.2
208+
+ jinja2==3.1.3
209+
+ markupsafe==2.1.5
210+
+ werkzeug==3.0.1
211+
Installed 1 executable: flask
212+
"###);
213+
214+
Ok(())
215+
}
216+
174217
#[test]
175218
fn tool_install_suggest_other_packages_with_executable() {
176219
let context = TestContext::new("3.12").with_filtered_exe_suffix();

docs/reference/cli.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,8 @@ uv tool install [OPTIONS] <PACKAGE>
32403240

32413241
</dd><dt><code>--with</code> <i>with</i></dt><dd><p>Include the following extra requirements</p>
32423242

3243+
</dd><dt><code>--with-editable</code> <i>with-editable</i></dt><dd><p>Include the given packages as editables</p>
3244+
32433245
</dd><dt><code>--with-requirements</code> <i>with-requirements</i></dt><dd><p>Run all requirements listed in the given <code>requirements.txt</code> files</p>
32443246

32453247
</dd></dl>

0 commit comments

Comments
 (0)