Skip to content

Commit 07038db

Browse files
committed
Remove PythonPreference toggle based on UV_TEST_PYTHON_PATH
1 parent 38beb2b commit 07038db

File tree

6 files changed

+40
-49
lines changed

6 files changed

+40
-49
lines changed

crates/uv-python/src/discovery.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn python_executables_from_installed<'a>(
328328
})
329329
.flatten();
330330

331-
let from_windows = std::iter::once_with(move || {
331+
let from_windows_registry = std::iter::once_with(move || {
332332
#[cfg(windows)]
333333
{
334334
// Skip interpreter probing if we already know the version doesn't match.
@@ -376,14 +376,14 @@ fn python_executables_from_installed<'a>(
376376
PythonPreference::Managed => Box::new(
377377
from_managed_installations
378378
.chain(from_search_path)
379-
.chain(from_windows),
379+
.chain(from_windows_registry),
380380
),
381381
PythonPreference::System => Box::new(
382382
from_search_path
383-
.chain(from_windows)
383+
.chain(from_windows_registry)
384384
.chain(from_managed_installations),
385385
),
386-
PythonPreference::OnlySystem => Box::new(from_search_path.chain(from_windows)),
386+
PythonPreference::OnlySystem => Box::new(from_search_path.chain(from_windows_registry)),
387387
}
388388
}
389389

@@ -1522,15 +1522,6 @@ impl PythonPreference {
15221522
}
15231523
}
15241524

1525-
/// Return the default [`PythonPreference`], respecting the `UV_TEST_PYTHON_PATH` variable.
1526-
pub fn default_from_env() -> Self {
1527-
if env::var_os("UV_TEST_PYTHON_PATH").is_some() {
1528-
Self::OnlySystem
1529-
} else {
1530-
Self::default()
1531-
}
1532-
}
1533-
15341525
pub(crate) fn allows_managed(self) -> bool {
15351526
matches!(self, Self::Managed | Self::OnlyManaged)
15361527
}

crates/uv/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl GlobalSettings {
120120
python_preference: args
121121
.python_preference
122122
.combine(workspace.and_then(|workspace| workspace.globals.python_preference))
123-
.unwrap_or_else(PythonPreference::default_from_env),
123+
.unwrap_or_default(),
124124
python_downloads: flag(args.allow_python_downloads, args.no_python_downloads)
125125
.map(PythonDownloads::from)
126126
.combine(env(env::UV_PYTHON_DOWNLOADS))

crates/uv/tests/lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ fn lock_requires_python() -> Result<()> {
33783378
----- stdout -----
33793379

33803380
----- stderr -----
3381-
error: No interpreter found for Python >=3.12 in system path
3381+
error: No interpreter found for Python >=3.12 in managed installations or system path
33823382
"###);
33833383

33843384
Ok(())

crates/uv/tests/python_find.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn python_find() {
3131
----- stdout -----
3232
3333
----- stderr -----
34-
error: No interpreter found in virtual environments or system path
34+
error: No interpreter found in virtual environments, managed installations, or system path
3535
"###);
3636
}
3737

@@ -127,7 +127,7 @@ fn python_find() {
127127
----- stdout -----
128128
129129
----- stderr -----
130-
error: No interpreter found for PyPy in virtual environments or system path
130+
error: No interpreter found for PyPy in virtual environments, managed installations, or system path
131131
"###);
132132
}
133133

@@ -443,7 +443,7 @@ fn python_find_unsupported_version() {
443443
----- stdout -----
444444
445445
----- stderr -----
446-
error: No interpreter found for Python 4.2 in virtual environments or system path
446+
error: No interpreter found for Python 4.2 in virtual environments, managed installations, or system path
447447
"###);
448448

449449
// Request a low version with a range
@@ -453,7 +453,7 @@ fn python_find_unsupported_version() {
453453
----- stdout -----
454454
455455
----- stderr -----
456-
error: No interpreter found for Python <3.0 in virtual environments or system path
456+
error: No interpreter found for Python <3.0 in virtual environments, managed installations, or system path
457457
"###);
458458

459459
// Request free-threaded Python on unsupported version

crates/uv/tests/python_pin.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn python_pin() {
172172
Updated `.python-version` from `[PYTHON-3.11]` -> `pypy`
173173
174174
----- stderr -----
175-
warning: No interpreter found for PyPy in system path
175+
warning: No interpreter found for PyPy in managed installations or system path
176176
"###);
177177

178178
let python_version = context.read(PYTHON_VERSION_FILENAME);
@@ -192,7 +192,7 @@ fn python_pin() {
192192
Updated `.python-version` from `pypy` -> `3.7`
193193
194194
----- stderr -----
195-
warning: No interpreter found for Python 3.7 in system path
195+
warning: No interpreter found for Python 3.7 in managed installations or system path
196196
"###);
197197

198198
let python_version = context.read(PYTHON_VERSION_FILENAME);
@@ -216,7 +216,7 @@ fn python_pin_no_python() {
216216
Pinned `.python-version` to `3.12`
217217
218218
----- stderr -----
219-
warning: No interpreter found for Python 3.12 in system path
219+
warning: No interpreter found for Python 3.12 in managed installations or system path
220220
"###);
221221
}
222222

@@ -413,7 +413,7 @@ fn warning_pinned_python_version_not_installed() -> anyhow::Result<()> {
413413
3.12
414414
415415
----- stderr -----
416-
warning: Failed to resolve pinned Python version `3.12`: No interpreter found for Python 3.12 in system path
416+
warning: Failed to resolve pinned Python version `3.12`: No interpreter found for Python 3.12 in managed installations or system path
417417
"###);
418418
}
419419

@@ -441,7 +441,7 @@ fn python_pin_resolve_no_python() {
441441
----- stdout -----
442442
443443
----- stderr -----
444-
error: No interpreter found for Python 3.12 in system path
444+
error: No interpreter found for Python 3.12 in managed installations or system path
445445
"###);
446446
}
447447
}
@@ -597,7 +597,7 @@ fn python_pin_resolve() {
597597
----- stdout -----
598598
599599
----- stderr -----
600-
error: No interpreter found for PyPy in system path
600+
error: No interpreter found for PyPy in managed installations or system path
601601
"###);
602602

603603
let python_version = context.read(PYTHON_VERSION_FILENAME);
@@ -618,7 +618,7 @@ fn python_pin_resolve() {
618618
----- stdout -----
619619
620620
----- stderr -----
621-
error: No interpreter found for Python 3.7 in system path
621+
error: No interpreter found for Python 3.7 in managed installations or system path
622622
"###);
623623

624624
let python_version = context.read(PYTHON_VERSION_FILENAME);

crates/uv/tests/show_settings.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
6060
connectivity: Online,
6161
show_settings: true,
6262
preview: Disabled,
63-
python_preference: OnlySystem,
63+
python_preference: Managed,
6464
python_downloads: Automatic,
6565
no_progress: false,
6666
}
@@ -202,7 +202,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
202202
connectivity: Online,
203203
show_settings: true,
204204
preview: Disabled,
205-
python_preference: OnlySystem,
205+
python_preference: Managed,
206206
python_downloads: Automatic,
207207
no_progress: false,
208208
}
@@ -345,7 +345,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
345345
connectivity: Online,
346346
show_settings: true,
347347
preview: Disabled,
348-
python_preference: OnlySystem,
348+
python_preference: Managed,
349349
python_downloads: Automatic,
350350
no_progress: false,
351351
}
@@ -520,7 +520,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
520520
connectivity: Online,
521521
show_settings: true,
522522
preview: Disabled,
523-
python_preference: OnlySystem,
523+
python_preference: Managed,
524524
python_downloads: Automatic,
525525
no_progress: false,
526526
}
@@ -664,7 +664,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
664664
connectivity: Online,
665665
show_settings: true,
666666
preview: Disabled,
667-
python_preference: OnlySystem,
667+
python_preference: Managed,
668668
python_downloads: Automatic,
669669
no_progress: false,
670670
}
@@ -794,7 +794,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
794794
connectivity: Online,
795795
show_settings: true,
796796
preview: Disabled,
797-
python_preference: OnlySystem,
797+
python_preference: Managed,
798798
python_downloads: Automatic,
799799
no_progress: false,
800800
}
@@ -961,7 +961,7 @@ fn resolve_index_url() -> anyhow::Result<()> {
961961
connectivity: Online,
962962
show_settings: true,
963963
preview: Disabled,
964-
python_preference: OnlySystem,
964+
python_preference: Managed,
965965
python_downloads: Automatic,
966966
no_progress: false,
967967
}
@@ -1128,7 +1128,7 @@ fn resolve_index_url() -> anyhow::Result<()> {
11281128
connectivity: Online,
11291129
show_settings: true,
11301130
preview: Disabled,
1131-
python_preference: OnlySystem,
1131+
python_preference: Managed,
11321132
python_downloads: Automatic,
11331133
no_progress: false,
11341134
}
@@ -1340,7 +1340,7 @@ fn resolve_find_links() -> anyhow::Result<()> {
13401340
connectivity: Online,
13411341
show_settings: true,
13421342
preview: Disabled,
1343-
python_preference: OnlySystem,
1343+
python_preference: Managed,
13441344
python_downloads: Automatic,
13451345
no_progress: false,
13461346
}
@@ -1506,7 +1506,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
15061506
connectivity: Online,
15071507
show_settings: true,
15081508
preview: Disabled,
1509-
python_preference: OnlySystem,
1509+
python_preference: Managed,
15101510
python_downloads: Automatic,
15111511
no_progress: false,
15121512
}
@@ -1642,7 +1642,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
16421642
connectivity: Online,
16431643
show_settings: true,
16441644
preview: Disabled,
1645-
python_preference: OnlySystem,
1645+
python_preference: Managed,
16461646
python_downloads: Automatic,
16471647
no_progress: false,
16481648
}
@@ -1806,7 +1806,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
18061806
connectivity: Online,
18071807
show_settings: true,
18081808
preview: Disabled,
1809-
python_preference: OnlySystem,
1809+
python_preference: Managed,
18101810
python_downloads: Automatic,
18111811
no_progress: false,
18121812
}
@@ -1994,7 +1994,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
19941994
connectivity: Online,
19951995
show_settings: true,
19961996
preview: Disabled,
1997-
python_preference: OnlySystem,
1997+
python_preference: Managed,
19981998
python_downloads: Automatic,
19991999
no_progress: false,
20002000
}
@@ -2120,7 +2120,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
21202120
connectivity: Online,
21212121
show_settings: true,
21222122
preview: Disabled,
2123-
python_preference: OnlySystem,
2123+
python_preference: Managed,
21242124
python_downloads: Automatic,
21252125
no_progress: false,
21262126
}
@@ -2246,7 +2246,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
22462246
connectivity: Online,
22472247
show_settings: true,
22482248
preview: Disabled,
2249-
python_preference: OnlySystem,
2249+
python_preference: Managed,
22502250
python_downloads: Automatic,
22512251
no_progress: false,
22522252
}
@@ -2374,7 +2374,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
23742374
connectivity: Online,
23752375
show_settings: true,
23762376
preview: Disabled,
2377-
python_preference: OnlySystem,
2377+
python_preference: Managed,
23782378
python_downloads: Automatic,
23792379
no_progress: false,
23802380
}
@@ -2521,7 +2521,7 @@ fn resolve_tool() -> anyhow::Result<()> {
25212521
connectivity: Online,
25222522
show_settings: true,
25232523
preview: Disabled,
2524-
python_preference: OnlySystem,
2524+
python_preference: Managed,
25252525
python_downloads: Automatic,
25262526
no_progress: false,
25272527
}
@@ -2678,7 +2678,7 @@ fn resolve_poetry_toml() -> anyhow::Result<()> {
26782678
connectivity: Online,
26792679
show_settings: true,
26802680
preview: Disabled,
2681-
python_preference: OnlySystem,
2681+
python_preference: Managed,
26822682
python_downloads: Automatic,
26832683
no_progress: false,
26842684
}
@@ -2832,7 +2832,7 @@ fn resolve_both() -> anyhow::Result<()> {
28322832
connectivity: Online,
28332833
show_settings: true,
28342834
preview: Disabled,
2835-
python_preference: OnlySystem,
2835+
python_preference: Managed,
28362836
python_downloads: Automatic,
28372837
no_progress: false,
28382838
}
@@ -3001,7 +3001,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
30013001
connectivity: Online,
30023002
show_settings: true,
30033003
preview: Disabled,
3004-
python_preference: OnlySystem,
3004+
python_preference: Managed,
30053005
python_downloads: Automatic,
30063006
no_progress: false,
30073007
}
@@ -3245,7 +3245,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> {
32453245
connectivity: Online,
32463246
show_settings: true,
32473247
preview: Disabled,
3248-
python_preference: OnlySystem,
3248+
python_preference: Managed,
32493249
python_downloads: Automatic,
32503250
no_progress: false,
32513251
}
@@ -3374,7 +3374,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> {
33743374
connectivity: Online,
33753375
show_settings: true,
33763376
preview: Disabled,
3377-
python_preference: OnlySystem,
3377+
python_preference: Managed,
33783378
python_downloads: Automatic,
33793379
no_progress: false,
33803380
}
@@ -3511,7 +3511,7 @@ fn allow_insecure_host() -> anyhow::Result<()> {
35113511
connectivity: Online,
35123512
show_settings: true,
35133513
preview: Disabled,
3514-
python_preference: OnlySystem,
3514+
python_preference: Managed,
35153515
python_downloads: Automatic,
35163516
no_progress: false,
35173517
}

0 commit comments

Comments
 (0)