Skip to content

Commit

Permalink
add: move UvBuilder out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsp committed Mar 11, 2024
1 parent c975a79 commit d0243b7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions rye/src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,16 @@ fn resolve_requirements_with_uv(
) -> Result<(), Error> {
let venv_path = pyproject_toml.venv_path();
let py_bin = get_venv_python_bin(&venv_path);
let sources = ExpandedSources::from_sources(&pyproject_toml.sources()?)?;

let uv = UvBuilder::new()
.with_output(output.quieter())
.with_sources(sources)
.ensure_exists()?
.venv(&venv_path, &py_bin, py_ver, None)?;

for req in requirements {
let sources = ExpandedSources::from_sources(&pyproject_toml.sources()?)?;

let mut new_req = UvBuilder::new()
.with_output(output.quieter())
.with_sources(sources)
.ensure_exists()?
.venv(&venv_path, &py_bin, py_ver, None)?
.resolve(py_ver, req, pre, env::var("__RYE_UV_EXCLUDE_NEWER").ok())?;
let mut new_req = uv.resolve(py_ver, req, pre, env::var("__RYE_UV_EXCLUDE_NEWER").ok())?;

// if a version or URL is already provided we just use the normalized package name but
// retain all old information.
Expand Down

0 comments on commit d0243b7

Please sign in to comment.