Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from semver::Version to pep440_rs::Version for Python version comparisons during release #328

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object = "0.32.2"
octocrab = { version = "0.34.1", features = ["rustls", "stream"] }
once_cell = "1.19.0"
pdb = "0.8.0"
pep440_rs = "0.6.6"
rayon = "1.8.1"
reqwest = { version = "0.11.24", features = ["rustls", "stream"] }
scroll = "0.12.0"
Expand Down
6 changes: 4 additions & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::str::FromStr;

use crate::release::{bootstrap_llvm, produce_install_only_stripped};
use {
crate::release::{produce_install_only, RELEASE_TRIPLES},
Expand Down Expand Up @@ -355,8 +357,8 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
for version in python_versions {
for (triple, release) in RELEASE_TRIPLES.iter() {
if let Some(req) = &release.python_version_requirement {
let python_version = semver::Version::parse(version)?;
if !req.matches(&python_version) {
let python_version = pep440_rs::Version::from_str(version)?;
if !req.contains(&python_version) {
continue;
}
}
Expand Down
29 changes: 16 additions & 13 deletions src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ use anyhow::Context;
use futures::StreamExt;

use object::FileKind;
use std::process::{Command, Stdio};
use std::{
process::{Command, Stdio},
str::FromStr,
};
use url::Url;
use {
crate::json::parse_python_json,
anyhow::{anyhow, Result},
once_cell::sync::Lazy,
semver::VersionReq,
pep440_rs::VersionSpecifier,
std::{
collections::BTreeMap,
io::{BufRead, Read, Write},
Expand All @@ -27,7 +30,7 @@ pub struct TripleRelease {
/// Build suffix to use for the `install_only` artifact.
pub install_only_suffix: &'static str,
/// Minimum Python version this triple is released for.
pub python_version_requirement: Option<VersionReq>,
pub python_version_requirement: Option<VersionSpecifier>,
}

pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::new(|| {
Expand Down Expand Up @@ -107,7 +110,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
TripleRelease {
suffixes: linux_suffixes_nopgo.clone(),
install_only_suffix: "lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);

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

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

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

Expand All @@ -151,23 +154,23 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
TripleRelease {
suffixes: linux_suffixes_pgo.clone(),
install_only_suffix: "pgo+lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);
h.insert(
"x86_64_v3-unknown-linux-gnu",
TripleRelease {
suffixes: linux_suffixes_pgo.clone(),
install_only_suffix: "pgo+lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);
h.insert(
"x86_64_v4-unknown-linux-gnu",
TripleRelease {
suffixes: linux_suffixes_nopgo.clone(),
install_only_suffix: "lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);
h.insert(
Expand All @@ -183,23 +186,23 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
TripleRelease {
suffixes: linux_suffixes_nopgo.clone(),
install_only_suffix: "lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);
h.insert(
"x86_64_v3-unknown-linux-musl",
TripleRelease {
suffixes: linux_suffixes_nopgo.clone(),
install_only_suffix: "lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);
h.insert(
"x86_64_v4-unknown-linux-musl",
TripleRelease {
suffixes: linux_suffixes_nopgo.clone(),
install_only_suffix: "lto",
python_version_requirement: Some(VersionReq::parse(">=3.9").unwrap()),
python_version_requirement: Some(VersionSpecifier::from_str(">=3.9").unwrap()),
},
);

Expand Down
Loading