Skip to content

Commit ef71d13

Browse files
authored
Switch from semver::Version to pep440_rs::Version for Python version comparisons during release (#328)
Otherwise, we fail to parse `3.13.0rc2` because the Python prerelease syntax does not match the Cargo SemVer syntax
1 parent 3d279ba commit ef71d13

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

Cargo.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ object = "0.32.2"
2323
octocrab = { version = "0.34.1", features = ["rustls", "stream"] }
2424
once_cell = "1.19.0"
2525
pdb = "0.8.0"
26+
pep440_rs = "0.6.6"
2627
rayon = "1.8.1"
2728
reqwest = { version = "0.11.24", features = ["rustls", "stream"] }
2829
scroll = "0.12.0"

src/github.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5+
use std::str::FromStr;
6+
57
use crate::release::{bootstrap_llvm, produce_install_only_stripped};
68
use {
79
crate::release::{produce_install_only, RELEASE_TRIPLES},
@@ -355,8 +357,8 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
355357
for version in python_versions {
356358
for (triple, release) in RELEASE_TRIPLES.iter() {
357359
if let Some(req) = &release.python_version_requirement {
358-
let python_version = semver::Version::parse(version)?;
359-
if !req.matches(&python_version) {
360+
let python_version = pep440_rs::Version::from_str(version)?;
361+
if !req.contains(&python_version) {
360362
continue;
361363
}
362364
}

src/release.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ use anyhow::Context;
66
use futures::StreamExt;
77

88
use object::FileKind;
9-
use std::process::{Command, Stdio};
9+
use std::{
10+
process::{Command, Stdio},
11+
str::FromStr,
12+
};
1013
use url::Url;
1114
use {
1215
crate::json::parse_python_json,
1316
anyhow::{anyhow, Result},
1417
once_cell::sync::Lazy,
15-
semver::VersionReq,
18+
pep440_rs::VersionSpecifier,
1619
std::{
1720
collections::BTreeMap,
1821
io::{BufRead, Read, Write},
@@ -27,7 +30,7 @@ pub struct TripleRelease {
2730
/// Build suffix to use for the `install_only` artifact.
2831
pub install_only_suffix: &'static str,
2932
/// Minimum Python version this triple is released for.
30-
pub python_version_requirement: Option<VersionReq>,
33+
pub python_version_requirement: Option<VersionSpecifier>,
3134
}
3235

3336
pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::new(|| {
@@ -107,7 +110,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
107110
TripleRelease {
108111
suffixes: linux_suffixes_nopgo.clone(),
109112
install_only_suffix: "lto",
110-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
113+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
111114
},
112115
);
113116

@@ -116,7 +119,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
116119
TripleRelease {
117120
suffixes: linux_suffixes_nopgo.clone(),
118121
install_only_suffix: "lto",
119-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
122+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
120123
},
121124
);
122125

@@ -125,7 +128,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
125128
TripleRelease {
126129
suffixes: linux_suffixes_nopgo.clone(),
127130
install_only_suffix: "lto",
128-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
131+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
129132
},
130133
);
131134

@@ -134,7 +137,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
134137
TripleRelease {
135138
suffixes: linux_suffixes_nopgo.clone(),
136139
install_only_suffix: "lto",
137-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
140+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
138141
},
139142
);
140143

@@ -151,23 +154,23 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
151154
TripleRelease {
152155
suffixes: linux_suffixes_pgo.clone(),
153156
install_only_suffix: "pgo+lto",
154-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
157+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
155158
},
156159
);
157160
h.insert(
158161
"x86_64_v3-unknown-linux-gnu",
159162
TripleRelease {
160163
suffixes: linux_suffixes_pgo.clone(),
161164
install_only_suffix: "pgo+lto",
162-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
165+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
163166
},
164167
);
165168
h.insert(
166169
"x86_64_v4-unknown-linux-gnu",
167170
TripleRelease {
168171
suffixes: linux_suffixes_nopgo.clone(),
169172
install_only_suffix: "lto",
170-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
173+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
171174
},
172175
);
173176
h.insert(
@@ -183,23 +186,23 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
183186
TripleRelease {
184187
suffixes: linux_suffixes_nopgo.clone(),
185188
install_only_suffix: "lto",
186-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
189+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
187190
},
188191
);
189192
h.insert(
190193
"x86_64_v3-unknown-linux-musl",
191194
TripleRelease {
192195
suffixes: linux_suffixes_nopgo.clone(),
193196
install_only_suffix: "lto",
194-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
197+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
195198
},
196199
);
197200
h.insert(
198201
"x86_64_v4-unknown-linux-musl",
199202
TripleRelease {
200203
suffixes: linux_suffixes_nopgo.clone(),
201204
install_only_suffix: "lto",
202-
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
205+
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
203206
},
204207
);
205208

0 commit comments

Comments
 (0)