Skip to content

Commit ae06205

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

File tree

1 file changed

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

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,18 @@ 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 if let Some(request) = request_from_version_file(&CWD).await? {
449+
Some(request)
450+
} else {
451+
None
452+
};
453+
444454
let python = PythonInstallation::find_or_download(
445-
python.as_deref().map(PythonRequest::parse),
455+
python_request,
446456
// No opt-in is required for system environments, since we are not mutating it.
447457
EnvironmentPreference::Any,
448458
python_preference,

0 commit comments

Comments
 (0)