Skip to content

Commit

Permalink
update for rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Jun 10, 2024
1 parent 1a3da09 commit c8f0d20
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions crates/uv/src/commands/project/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub(crate) async fn add(

// Find the project requirements.
let project = ProjectWorkspace::discover(&std::env::current_dir()?, None).await?;
let mut pyproject = PyProjectTomlMut::from_toml(project.current_project().pyproject_toml())?;

let mut pyproject = PyProjectTomlMut::from_toml(project.current_project().pyproject_toml())?;
for req in requirements {
let req = Requirement::from(LenientRequirement::from_str(&req)?);
pyproject.add_dependency(&req)?;
Expand All @@ -41,7 +41,7 @@ pub(crate) async fn add(
)?;

// Discover or create the virtual environment.
let venv = project::init_environment(&project, preview, cache, printer)?;
let venv = project::init_environment(project.workspace(), preview, cache, printer)?;

let index_locations = IndexLocations::default();
let upgrade = Upgrade::default();
Expand All @@ -50,9 +50,17 @@ pub(crate) async fn add(
let dev = false; // We only add regular dependencies currently.

// Lock and sync the environment.
let root_project_name = project
.current_project()
.pyproject_toml()
.project
.as_ref()
.map(|project| project.name.clone());

let lock = project::lock::do_lock(
&project,
&venv,
root_project_name,
project.workspace(),
venv.interpreter(),
&index_locations,
upgrade,
exclude_newer,
Expand Down
16 changes: 12 additions & 4 deletions crates/uv/src/commands/project/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub(crate) async fn remove(

// Find the project requirements.
let project = ProjectWorkspace::discover(&std::env::current_dir()?, None).await?;
let mut pyproject = PyProjectTomlMut::from_toml(project.current_project().pyproject_toml())?;

let mut pyproject = PyProjectTomlMut::from_toml(project.current_project().pyproject_toml())?;
for req in requirements {
let req = Requirement::from(LenientRequirement::from_str(&req)?);
if pyproject.remove_dependency(&req)?.is_none() {
Expand All @@ -46,7 +46,7 @@ pub(crate) async fn remove(
)?;

// Discover or create the virtual environment.
let venv = project::init_environment(&project, preview, cache, printer)?;
let venv = project::init_environment(project.workspace(), preview, cache, printer)?;

let index_locations = IndexLocations::default();
let upgrade = Upgrade::default();
Expand All @@ -55,9 +55,17 @@ pub(crate) async fn remove(
let dev = false; // We only add regular dependencies currently.

// Lock and sync the environment.
let root_project_name = project
.current_project()
.pyproject_toml()
.project
.as_ref()
.map(|project| project.name.clone());

let lock = project::lock::do_lock(
&project,
&venv,
root_project_name,
project.workspace(),
venv.interpreter(),
&index_locations,
upgrade,
exclude_newer,
Expand Down

0 comments on commit c8f0d20

Please sign in to comment.