Skip to content

Commit 26d6452

Browse files
committed
Fix is_managed check for upgradable Python installs
1 parent b27c2d1 commit 26d6452

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/uv-python/src/interpreter.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,7 @@ impl Interpreter {
292292
return false;
293293
};
294294

295-
installations
296-
.find_all()
297-
.into_iter()
298-
.flatten()
299-
.any(|install| install.path() == self.sys_base_prefix)
295+
self.sys_base_prefix.starts_with(installations.root())
300296
}
301297

302298
/// Returns `Some` if the environment is externally managed, optionally including an error

crates/uv/tests/it/venv.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ fn venv_python_preference() {
13481348
----- stderr -----
13491349
Using CPython 3.11.[X] interpreter at: [PYTHON-3.11]
13501350
Creating virtual environment at: .venv
1351+
warning: A virtual environment already exists at `.venv`. In the future, uv will require `--clear` to replace it
13511352
Activate with: source .venv/[BIN]/activate
13521353
");
13531354

@@ -1359,6 +1360,7 @@ fn venv_python_preference() {
13591360
----- stderr -----
13601361
Using CPython 3.11.[X] interpreter at: [PYTHON-3.11]
13611362
Creating virtual environment at: .venv
1363+
warning: A virtual environment already exists at `.venv`. In the future, uv will require `--clear` to replace it
13621364
Activate with: source .venv/[BIN]/activate
13631365
");
13641366

@@ -1370,6 +1372,7 @@ fn venv_python_preference() {
13701372
----- stderr -----
13711373
Using CPython 3.12.[X] interpreter at: [PYTHON-3.12]
13721374
Creating virtual environment at: .venv
1375+
warning: A virtual environment already exists at `.venv`. In the future, uv will require `--clear` to replace it
13731376
Activate with: source .venv/[BIN]/activate
13741377
");
13751378

@@ -1381,6 +1384,7 @@ fn venv_python_preference() {
13811384
----- stderr -----
13821385
Using CPython 3.12.[X] interpreter at: [PYTHON-3.12]
13831386
Creating virtual environment at: .venv
1387+
warning: A virtual environment already exists at `.venv`. In the future, uv will require `--clear` to replace it
13841388
Activate with: source .venv/[BIN]/activate
13851389
");
13861390
}

0 commit comments

Comments
 (0)