Skip to content

Commit

Permalink
Support path-based dependencies in virtual projects with uv enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Mar 1, 2024
1 parent 2111778 commit 50aa278
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions rye/src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,23 +468,29 @@ fn resolve_requirements_with_uv(
if let Ok(dt) = env::var("__RYE_UV_EXCLUDE_NEWER") {
cmd.arg("--exclude-newer").arg(dt);
}
let sources = ExpandedSources::from_sources(&pyproject_toml.sources()?)?;
sources.add_as_pip_args(&mut cmd);
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
let child_stdin = child.stdin.as_mut().unwrap();
writeln!(child_stdin, "{}", req)?;

let rv = child.wait_with_output()?;
if !rv.status.success() {
let log = String::from_utf8_lossy(&rv.stderr);
bail!("failed to resolve packages:\n{}", log);
}

let mut new_req: Requirement = String::from_utf8_lossy(&rv.stdout).parse()?;
let mut new_req = match req.version_or_url {
Some(VersionOrUrl::Url(_)) => req.clone(),
_ => {
let sources = ExpandedSources::from_sources(&pyproject_toml.sources()?)?;
sources.add_as_pip_args(&mut cmd);
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
let child_stdin = child.stdin.as_mut().unwrap();
writeln!(child_stdin, "{}", req)?;

let rv = child.wait_with_output()?;
if !rv.status.success() {
let log = String::from_utf8_lossy(&rv.stderr);
bail!("failed to resolve packages:\n{}", log);
}
String::from_utf8_lossy(&rv.stdout).parse()?
}
};

if let Some(ref mut version_or_url) = new_req.version_or_url {
if let VersionOrUrl::VersionSpecifier(ref mut specs) = version_or_url {
*version_or_url = VersionOrUrl::VersionSpecifier(VersionSpecifiers::from_iter({
Expand Down

0 comments on commit 50aa278

Please sign in to comment.