Skip to content

Commit 73eaf2e

Browse files
authored
fix(python): respect precompiled flavor when excluding freethreaded builds (#8745)
Previously, if any flavor was specified (e.g., 'install_only_stripped'), the freethreaded exclusion was skipped, causing 'mise lock' to sometimes pick the freethreaded build incorrectly. Now it only allows freethreaded builds if the requested flavor specifically includes 'freethreaded'. Fixes #8739 *This PR was generated by an AI.*
1 parent e1b8ca4 commit 73eaf2e

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Test that precompiled_flavor setting is respected in lockfile generation
4+
# Regression test for https://github.com/jdx/mise/discussions/8739
5+
export MISE_LOCKFILE=1
6+
7+
detect_platform
8+
9+
cat <<EOF >mise.toml
10+
[tools]
11+
python = "3.13.5"
12+
13+
[settings.python]
14+
precompiled_flavor = "install_only_stripped"
15+
EOF
16+
17+
rm -f mise.lock
18+
19+
mise lock --platform "$MISE_PLATFORM"
20+
21+
# Verify lockfile does NOT contain freethreaded URLs
22+
assert_not_contains "cat mise.lock" "freethreaded"
23+
24+
# Verify lockfile contains the correct flavor
25+
assert_contains "cat mise.lock" "install_only_stripped"
26+
27+
rm -f mise.lock mise.toml
28+
29+
echo "Python lockfile flavor test passed!"

src/plugins/core/python.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl PythonPlugin {
203203
let versions = raw
204204
.lines()
205205
.filter(|v| v.contains(&platform))
206-
.filter(|v| flavor.is_some() || !v.contains("freethreaded"))
206+
.filter(|v| filter_freethreaded(v, &flavor))
207207
.flat_map(|v| {
208208
// cpython-3.9.5+20210525 or cpython-3.9.5rc3+20210525
209209
regex!(r"^cpython-(\d+\.\d+\.[\da-z]+)\+(\d+).*")
@@ -504,7 +504,7 @@ impl PythonPlugin {
504504
let result = raw
505505
.lines()
506506
.filter(|v| v.contains(&platform))
507-
.filter(|v| flavor.is_some() || !v.contains("freethreaded"))
507+
.filter(|v| filter_freethreaded(v, &flavor))
508508
.flat_map(|v| {
509509
regex!(r"^cpython-(\d+\.\d+\.[\da-z]+)\+(\d+).*")
510510
.captures(v)
@@ -825,3 +825,7 @@ fn ensure_not_windows() -> eyre::Result<()> {
825825
}
826826
Ok(())
827827
}
828+
829+
fn filter_freethreaded(v: &str, flavor: &Option<String>) -> bool {
830+
flavor.as_ref().is_some_and(|f| f.contains("freethreaded")) || !v.contains("freethreaded")
831+
}

0 commit comments

Comments
 (0)