Skip to content

Commit 2a8f458

Browse files
committed
Respect .python-version files in uv run outside projects
1 parent 45894e0 commit 2a8f458

File tree

1 file changed

+9
-1
lines changed
  • crates/uv/src/commands/project

1 file changed

+9
-1
lines changed

crates/uv/src/commands/project/run.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,16 @@ pub(crate) async fn run(
441441
.connectivity(connectivity)
442442
.native_tls(native_tls);
443443

444+
// (1) Explicit request from user
445+
let python_request = if let Some(request) = python.as_deref() {
446+
Some(PythonRequest::parse(request))
447+
// (2) Request from `.python-version`
448+
} else {
449+
request_from_version_file(&CWD).await?
450+
};
451+
444452
let python = PythonInstallation::find_or_download(
445-
python.as_deref().map(PythonRequest::parse),
453+
python_request,
446454
// No opt-in is required for system environments, since we are not mutating it.
447455
EnvironmentPreference::Any,
448456
python_preference,

0 commit comments

Comments
 (0)