Skip to content

Commit 09bc4f5

Browse files
authored
Include free-threaded builds in the release artifacts (#336)
1 parent 1baca22 commit 09bc4f5

File tree

2 files changed

+134
-7
lines changed

2 files changed

+134
-7
lines changed

src/github.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
234234

235235
let build_suffix = &stripped_name[triple_start + triple.len() + 1..];
236236

237-
if !release
238-
.suffixes
239-
.iter()
240-
.any(|suffix| build_suffix == *suffix)
241-
{
237+
if !release.suffixes(None).any(|suffix| build_suffix == suffix) {
242238
println!("{} not a release artifact for triple", name);
243239
continue;
244240
}
@@ -356,14 +352,14 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
356352
let mut wanted_filenames = BTreeMap::new();
357353
for version in python_versions {
358354
for (triple, release) in RELEASE_TRIPLES.iter() {
355+
let python_version = pep440_rs::Version::from_str(version)?;
359356
if let Some(req) = &release.python_version_requirement {
360-
let python_version = pep440_rs::Version::from_str(version)?;
361357
if !req.contains(&python_version) {
362358
continue;
363359
}
364360
}
365361

366-
for suffix in &release.suffixes {
362+
for suffix in release.suffixes(Some(&python_version)) {
367363
wanted_filenames.insert(
368364
format!(
369365
"cpython-{}-{}-{}-{}.tar.zst",

src/release.rs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,68 @@ pub struct TripleRelease {
3131
pub install_only_suffix: &'static str,
3232
/// Minimum Python version this triple is released for.
3333
pub python_version_requirement: Option<VersionSpecifier>,
34+
/// Additional build suffixes to release conditional on the Python version.
35+
pub conditional_suffixes: Vec<ConditionalSuffixes>,
36+
}
37+
38+
/// Describes additional build suffixes conditional on the Python version.
39+
///
40+
/// e.g., free-threaded builds which are only available for Python 3.13+.
41+
pub struct ConditionalSuffixes {
42+
/// The minimum Python version to include these suffixes for.
43+
pub python_version_requirement: VersionSpecifier,
44+
/// Build suffixes to release.
45+
pub suffixes: Vec<&'static str>,
46+
}
47+
48+
impl TripleRelease {
49+
pub fn suffixes<'a>(
50+
&'a self,
51+
python_version: Option<&'a pep440_rs::Version>,
52+
) -> impl Iterator<Item = &'static str> + 'a {
53+
self.suffixes
54+
.iter()
55+
.copied()
56+
.chain(
57+
self.conditional_suffixes
58+
.iter()
59+
.flat_map(move |conditional| {
60+
if python_version.is_none()
61+
|| python_version.is_some_and(|python_version| {
62+
conditional
63+
.python_version_requirement
64+
.contains(python_version)
65+
})
66+
{
67+
conditional.suffixes.iter().copied()
68+
} else {
69+
[].iter().copied()
70+
}
71+
}),
72+
)
73+
}
3474
}
3575

3676
pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::new(|| {
3777
let mut h = BTreeMap::new();
3878

3979
// macOS.
4080
let macos_suffixes = vec!["debug", "pgo", "pgo+lto"];
81+
let macos_suffixes_313 = vec![
82+
"freethreaded+debug",
83+
"freethreaded+pgo",
84+
"freethreaded+pgo+lto",
85+
];
4186
h.insert(
4287
"aarch64-apple-darwin",
4388
TripleRelease {
4489
suffixes: macos_suffixes.clone(),
4590
install_only_suffix: "pgo+lto",
4691
python_version_requirement: None,
92+
conditional_suffixes: vec![ConditionalSuffixes {
93+
python_version_requirement: VersionSpecifier::from_str(">=3.13.0rc0").unwrap(),
94+
suffixes: macos_suffixes_313.clone(),
95+
}],
4796
},
4897
);
4998
h.insert(
@@ -52,6 +101,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
52101
suffixes: macos_suffixes,
53102
install_only_suffix: "pgo+lto",
54103
python_version_requirement: None,
104+
conditional_suffixes: vec![ConditionalSuffixes {
105+
python_version_requirement: VersionSpecifier::from_str(">=3.13.0rc0").unwrap(),
106+
suffixes: macos_suffixes_313.clone(),
107+
}],
55108
},
56109
);
57110

@@ -62,6 +115,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
62115
suffixes: vec!["pgo"],
63116
install_only_suffix: "pgo",
64117
python_version_requirement: None,
118+
conditional_suffixes: vec![ConditionalSuffixes {
119+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
120+
suffixes: vec!["freethreaded+pgo"],
121+
}],
65122
},
66123
);
67124
h.insert(
@@ -70,6 +127,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
70127
suffixes: vec!["pgo"],
71128
install_only_suffix: "pgo",
72129
python_version_requirement: None,
130+
conditional_suffixes: vec![ConditionalSuffixes {
131+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
132+
suffixes: vec!["freethreaded+pgo"],
133+
}],
73134
},
74135
);
75136

@@ -81,6 +142,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
81142
suffixes: vec!["pgo"],
82143
install_only_suffix: "pgo",
83144
python_version_requirement: None,
145+
conditional_suffixes: vec![ConditionalSuffixes {
146+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
147+
suffixes: vec!["freethreaded+pgo"],
148+
}],
84149
},
85150
);
86151
h.insert(
@@ -89,19 +154,37 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
89154
suffixes: vec!["pgo"],
90155
install_only_suffix: "pgo",
91156
python_version_requirement: None,
157+
conditional_suffixes: vec![ConditionalSuffixes {
158+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
159+
suffixes: vec!["freethreaded+pgo"],
160+
}],
92161
},
93162
);
94163

95164
// Linux.
96165
let linux_suffixes_pgo = vec!["debug", "pgo", "pgo+lto"];
97166
let linux_suffixes_nopgo = vec!["debug", "lto", "noopt"];
167+
let linux_suffixes_pgo_freethreaded = vec![
168+
"freethreaded+debug",
169+
"freethreaded+pgo",
170+
"freethreaded+pgo+lto",
171+
];
172+
let linux_suffixes_nopgo_freethreaded = vec![
173+
"freethreaded+debug",
174+
"freethreaded+lto",
175+
"freethreaded+noopt",
176+
];
98177

99178
h.insert(
100179
"aarch64-unknown-linux-gnu",
101180
TripleRelease {
102181
suffixes: linux_suffixes_nopgo.clone(),
103182
install_only_suffix: "lto",
104183
python_version_requirement: None,
184+
conditional_suffixes: vec![ConditionalSuffixes {
185+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
186+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
187+
}],
105188
},
106189
);
107190

@@ -111,6 +194,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
111194
suffixes: linux_suffixes_nopgo.clone(),
112195
install_only_suffix: "lto",
113196
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
197+
conditional_suffixes: vec![ConditionalSuffixes {
198+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
199+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
200+
}],
114201
},
115202
);
116203

@@ -120,6 +207,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
120207
suffixes: linux_suffixes_nopgo.clone(),
121208
install_only_suffix: "lto",
122209
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
210+
conditional_suffixes: vec![ConditionalSuffixes {
211+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
212+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
213+
}],
123214
},
124215
);
125216

@@ -129,6 +220,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
129220
suffixes: linux_suffixes_nopgo.clone(),
130221
install_only_suffix: "lto",
131222
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
223+
conditional_suffixes: vec![ConditionalSuffixes {
224+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
225+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
226+
}],
132227
},
133228
);
134229

@@ -138,6 +233,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
138233
suffixes: linux_suffixes_nopgo.clone(),
139234
install_only_suffix: "lto",
140235
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
236+
conditional_suffixes: vec![ConditionalSuffixes {
237+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
238+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
239+
}],
141240
},
142241
);
143242

@@ -147,6 +246,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
147246
suffixes: linux_suffixes_pgo.clone(),
148247
install_only_suffix: "pgo+lto",
149248
python_version_requirement: None,
249+
conditional_suffixes: vec![ConditionalSuffixes {
250+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
251+
suffixes: linux_suffixes_pgo_freethreaded.clone(),
252+
}],
150253
},
151254
);
152255
h.insert(
@@ -155,6 +258,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
155258
suffixes: linux_suffixes_pgo.clone(),
156259
install_only_suffix: "pgo+lto",
157260
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
261+
conditional_suffixes: vec![ConditionalSuffixes {
262+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
263+
suffixes: linux_suffixes_pgo_freethreaded.clone(),
264+
}],
158265
},
159266
);
160267
h.insert(
@@ -163,6 +270,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
163270
suffixes: linux_suffixes_pgo.clone(),
164271
install_only_suffix: "pgo+lto",
165272
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
273+
conditional_suffixes: vec![ConditionalSuffixes {
274+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
275+
suffixes: linux_suffixes_pgo_freethreaded.clone(),
276+
}],
166277
},
167278
);
168279
h.insert(
@@ -171,6 +282,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
171282
suffixes: linux_suffixes_nopgo.clone(),
172283
install_only_suffix: "lto",
173284
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
285+
conditional_suffixes: vec![ConditionalSuffixes {
286+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
287+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
288+
}],
174289
},
175290
);
176291
h.insert(
@@ -179,6 +294,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
179294
suffixes: linux_suffixes_nopgo.clone(),
180295
install_only_suffix: "lto",
181296
python_version_requirement: None,
297+
conditional_suffixes: vec![ConditionalSuffixes {
298+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
299+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
300+
}],
182301
},
183302
);
184303
h.insert(
@@ -187,6 +306,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
187306
suffixes: linux_suffixes_nopgo.clone(),
188307
install_only_suffix: "lto",
189308
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
309+
conditional_suffixes: vec![ConditionalSuffixes {
310+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
311+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
312+
}],
190313
},
191314
);
192315
h.insert(
@@ -195,6 +318,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
195318
suffixes: linux_suffixes_nopgo.clone(),
196319
install_only_suffix: "lto",
197320
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
321+
conditional_suffixes: vec![ConditionalSuffixes {
322+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
323+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
324+
}],
198325
},
199326
);
200327
h.insert(
@@ -203,6 +330,10 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
203330
suffixes: linux_suffixes_nopgo.clone(),
204331
install_only_suffix: "lto",
205332
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
333+
conditional_suffixes: vec![ConditionalSuffixes {
334+
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
335+
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
336+
}],
206337
},
207338
);
208339

0 commit comments

Comments
 (0)