Skip to content

Commit

Permalink
Reject stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 23, 2024
1 parent 6fb27cf commit a3601eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 0 additions & 2 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,8 +1836,6 @@ pub struct RunArgs {
/// Run with all packages listed in the given `requirements.txt` files.
///
/// Using `pyproject.toml`, `setup.py`, or `setup.cfg` files is not allowed.
///
/// If `-` is provided, then requirements will be read from stdin.
#[arg(long, value_parser = parse_maybe_file_path)]
pub with_requirements: Vec<Maybe<PathBuf>>,

Expand Down
5 changes: 4 additions & 1 deletion crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use anyhow::{bail, Context, Result};
use itertools::Itertools;
Expand Down Expand Up @@ -72,6 +72,9 @@ pub(crate) async fn run(
RequirementsSource::SetupCfg(_) => {
bail!("Adding requirements from a `setup.cfg` is not supported in `uv run`");
}
RequirementsSource::RequirementsTxt(path) => if path == Path::new("-") {
bail!("Reading requirements from stdin is not supported in `uv run`");
}
_ => {}
}
}
Expand Down
16 changes: 16 additions & 0 deletions crates/uv/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,21 @@ fn run_requirements_txt() -> Result<()> {
+ sniffio==1.3.1
"###);

// But reject `-` as a requirements file.
uv_snapshot!(context.filters(), context.run()
.arg("--with-requirements")
.arg("-")
.arg("--with")
.arg("iniconfig")
.arg("main.py"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
warning: `uv run` is experimental and may change without warning
error: Reading requirements from stdin is not supported in `uv run`
"###);

Ok(())
}

0 comments on commit a3601eb

Please sign in to comment.