Skip to content

Commit

Permalink
Allow system Python discovery with --target and --prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 22, 2024
1 parent 536d038 commit fdb9185
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
19 changes: 11 additions & 8 deletions crates/uv/src/commands/pip/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,17 @@ pub(crate) async fn pip_install(
.collect();

// Detect the current Python interpreter.
let environment = PythonEnvironment::find(
&python
.as_deref()
.map(PythonRequest::parse)
.unwrap_or_default(),
EnvironmentPreference::from_system_flag(system, true),
&cache,
)?;
let environment = {
let mutable = !(target.is_some() || prefix.is_some());
PythonEnvironment::find(
&python
.as_deref()
.map(PythonRequest::parse)
.unwrap_or_default(),
EnvironmentPreference::from_system_flag(system, mutable),
&cache,
)?
};

report_target_environment(&environment, &cache, printer)?;

Expand Down
19 changes: 11 additions & 8 deletions crates/uv/src/commands/pip/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,17 @@ pub(crate) async fn pip_sync(
}

// Detect the current Python interpreter.
let environment = PythonEnvironment::find(
&python
.as_deref()
.map(PythonRequest::parse)
.unwrap_or_default(),
EnvironmentPreference::from_system_flag(system, true),
&cache,
)?;
let environment = {
let mutable = !(target.is_some() || prefix.is_some());
PythonEnvironment::find(
&python
.as_deref()
.map(PythonRequest::parse)
.unwrap_or_default(),
EnvironmentPreference::from_system_flag(system, mutable),
&cache,
)?
};

report_target_environment(&environment, &cache, printer)?;

Expand Down

0 comments on commit fdb9185

Please sign in to comment.