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

Support --with-editable in uv tool install #8472

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3514,6 +3514,10 @@ pub struct ToolInstallArgs {
#[arg(short, long)]
pub editable: bool,

/// Include the given packages as editables.
#[arg(long, value_delimiter = ',')]
pub with_editable: Vec<String>,

/// The package to install commands from.
///
/// This option is provided for parity with `uv tool run`, but is redundant with `package`.
Expand Down
5 changes: 5 additions & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
.with
.into_iter()
.map(RequirementsSource::from_with_package)
.chain(
args.with_editable
.into_iter()
.map(RequirementsSource::Editable),
)
.chain(
args.with_requirements
.into_iter()
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ pub(crate) struct ToolInstallSettings {
pub(crate) from: Option<String>,
pub(crate) with: Vec<String>,
pub(crate) with_requirements: Vec<PathBuf>,
pub(crate) with_editable: Vec<String>,
pub(crate) python: Option<String>,
pub(crate) refresh: Refresh,
pub(crate) options: ResolverInstallerOptions,
Expand All @@ -406,6 +407,7 @@ impl ToolInstallSettings {
editable,
from,
with,
with_editable,
with_requirements,
installer,
force,
Expand All @@ -427,6 +429,7 @@ impl ToolInstallSettings {
package,
from,
with,
with_editable,
with_requirements: with_requirements
.into_iter()
.filter_map(Maybe::into_option)
Expand Down
1 change: 1 addition & 0 deletions crates/uv/tests/it/show_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,7 @@ fn resolve_tool() -> anyhow::Result<()> {
from: None,
with: [],
with_requirements: [],
with_editable: [],
python: None,
refresh: None(
Timestamp(
Expand Down
45 changes: 44 additions & 1 deletion crates/uv/tests/it/tool_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use predicates::prelude::predicate;

use uv_static::EnvVars;

use crate::common::{uv_snapshot, TestContext};
use crate::common::{copy_dir_all, uv_snapshot, TestContext};

#[test]
fn tool_install() {
Expand Down Expand Up @@ -171,6 +171,49 @@ fn tool_install() {
});
}

#[test]
fn tool_install_with_editable() -> anyhow::Result<()> {
let context = TestContext::new("3.12").with_filtered_counts();
blueraft marked this conversation as resolved.
Show resolved Hide resolved
let tool_dir = context.temp_dir.child("tools");
let bin_dir = context.temp_dir.child("bin");
let anyio_local = context.temp_dir.child("src").child("anyio_local");
copy_dir_all(
context.workspace_root.join("scripts/packages/anyio_local"),
&anyio_local,
)?;

uv_snapshot!(context.filters(), context.tool_install()
.arg("--with-editable")
.arg("./src/anyio_local")
.arg("--with")
.arg("iniconfig")
.arg("flask")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str())
.env(EnvVars::PATH, bin_dir.as_os_str()), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved [N] packages in [TIME]
Prepared [N] packages in [TIME]
Installed [N] packages in [TIME]
+ anyio==4.3.0+foo (from file://[TEMP_DIR]/src/anyio_local)
+ blinker==1.7.0
+ click==8.1.7
+ flask==3.0.2
+ iniconfig==2.0.0
+ itsdangerous==2.1.2
+ jinja2==3.1.3
+ markupsafe==2.1.5
+ werkzeug==3.0.1
Installed 1 executable: flask
"###);

Ok(())
}

#[test]
fn tool_install_suggest_other_packages_with_executable() {
let context = TestContext::new("3.12").with_filtered_exe_suffix();
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3240,6 +3240,8 @@ uv tool install [OPTIONS] <PACKAGE>

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

</dd><dt><code>--with-editable</code> <i>with-editable</i></dt><dd><p>Include the given packages as editables</p>

</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>

</dd></dl>
Expand Down
Loading