Skip to content

Commit

Permalink
Respect .python-version files in uv run outside projects
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Aug 21, 2024
1 parent 45894e0 commit ae06205
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,18 @@ pub(crate) async fn run(
.connectivity(connectivity)
.native_tls(native_tls);

// (1) Explicit request from user
let python_request = if let Some(request) = python.as_deref() {
Some(PythonRequest::parse(request))
// (2) Request from `.python-version`
} else if let Some(request) = request_from_version_file(&CWD).await? {
Some(request)
} else {
None
};

let python = PythonInstallation::find_or_download(
python.as_deref().map(PythonRequest::parse),
python_request,
// No opt-in is required for system environments, since we are not mutating it.
EnvironmentPreference::Any,
python_preference,
Expand Down

0 comments on commit ae06205

Please sign in to comment.