From 82e9015815f9a764decdee3dec71b703931a34e9 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 7 Oct 2024 17:28:53 -0500 Subject: [PATCH] Drop Python 3.8 artifacts from the release (#340) We need more disk space for 3.13t and this seems like the most straight-forward way to get it? --- src/github.rs | 82 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/src/github.rs b/src/github.rs index b7d2cc5b..6556be67 100644 --- a/src/github.rs +++ b/src/github.rs @@ -33,7 +33,7 @@ async fn fetch_artifact( repo: &str, artifact: WorkflowListArtifact, ) -> Result { - println!("downloading {}", artifact.name); + println!("downloading artifact {}", artifact.name); let res = client .actions() @@ -107,6 +107,8 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() ) .build()?; + let release_version_range = pep440_rs::VersionSpecifier::from_str(">=3.9")?; + let workflows = client.workflows(org, repo); let mut workflow_names = HashMap::new(); @@ -208,9 +210,25 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() let name = zf.name().to_string(); + let parts = name.split('-').collect::>(); + + if parts[0] != "cpython" { + println!("ignoring {} not a cpython artifact", name); + continue; + }; + + let python_version = pep440_rs::Version::from_str(parts[1])?; + if !release_version_range.contains(&python_version) { + println!( + "{} not in release version range {}", + name, release_version_range + ); + continue; + } + // Iterate over `RELEASE_TRIPLES` in reverse-order to ensure that if any triple is a // substring of another, the longest match is used. - if let Some((triple, release)) = + let Some((triple, release)) = RELEASE_TRIPLES.iter().rev().find_map(|(triple, release)| { if name.contains(triple) { Some((triple, release)) @@ -218,39 +236,43 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() None } }) - { - let stripped_name = if let Some(s) = name.strip_suffix(".tar.zst") { - s - } else { - println!("{} not a .tar.zst artifact", name); - continue; - }; + else { + println!( + "ignoring {} does not match any registered release triples", + name + ); + continue; + }; - let stripped_name = &stripped_name[0..stripped_name.len() - "-YYYYMMDDTHHMM".len()]; + let stripped_name = if let Some(s) = name.strip_suffix(".tar.zst") { + s + } else { + println!("ignoring {} not a .tar.zst artifact", name); + continue; + }; - let triple_start = stripped_name - .find(triple) - .expect("validated triple presence above"); + let stripped_name = &stripped_name[0..stripped_name.len() - "-YYYYMMDDTHHMM".len()]; - let build_suffix = &stripped_name[triple_start + triple.len() + 1..]; + let triple_start = stripped_name + .find(triple) + .expect("validated triple presence above"); - if !release.suffixes(None).any(|suffix| build_suffix == suffix) { - println!("{} not a release artifact for triple", name); - continue; - } + let build_suffix = &stripped_name[triple_start + triple.len() + 1..]; - let dest_path = dest_dir.join(&name); - let mut buf = vec![]; - zf.read_to_end(&mut buf)?; - std::fs::write(&dest_path, &buf)?; + if !release.suffixes(None).any(|suffix| build_suffix == suffix) { + println!("ignoring {} not a release artifact for triple", name); + continue; + } - println!("releasing {}", name); + let dest_path = dest_dir.join(&name); + let mut buf = vec![]; + zf.read_to_end(&mut buf)?; + std::fs::write(&dest_path, &buf)?; - if build_suffix == release.install_only_suffix { - install_paths.push(dest_path); - } - } else { - println!("{} does not match any registered release triples", name); + println!("prepared {} for release", name); + + if build_suffix == release.install_only_suffix { + install_paths.push(dest_path); } } } @@ -271,7 +293,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() let dest_path = produce_install_only(path)?; println!( - "releasing {}", + "prepared {} for release", dest_path .file_name() .expect("should have file name") @@ -290,7 +312,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() let dest_path = produce_install_only_stripped(&dest_path, &llvm_dir)?; println!( - "releasing {}", + "prepared {} for release", dest_path .file_name() .expect("should have file name")