Skip to content

create install only assets for free-threaded builds #537

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()

println!("prepared {} for release", name);

if build_suffix == release.install_only_suffix {
if build_suffix == release.install_only_suffix(Some(&python_version)) {
install_paths.push(dest_path);
}
}
Expand Down
47 changes: 46 additions & 1 deletion src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct ConditionalSuffixes {
pub python_version_requirement: VersionSpecifier,
/// Build suffixes to release.
pub suffixes: Vec<&'static str>,
/// Build suffix to use for the `install_only` artifact.
pub install_only_suffix: &'static str,
}

impl TripleRelease {
Expand Down Expand Up @@ -71,6 +73,20 @@ impl TripleRelease {
}),
)
}

pub fn install_only_suffix<'a>(
&'a self,
python_version: Option<&'a pep440_rs::Version>,
) -> &'static str {
if let Some(version) = python_version {
for conditional in self.conditional_suffixes.iter() {
if conditional.python_version_requirement.contains(version) {
return conditional.install_only_suffix;
}
}
}
self.install_only_suffix
}
}

pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::new(|| {
Expand All @@ -79,6 +95,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
// macOS.
let macos_suffixes = vec!["debug", "pgo+lto"];
let macos_suffixes_313 = vec!["freethreaded+debug", "freethreaded+pgo+lto"];
let macos_install_only_suffix_313 = "freethreaded+pgo+lto";
h.insert(
"aarch64-apple-darwin",
TripleRelease {
Expand All @@ -88,6 +105,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13.0rc0").unwrap(),
suffixes: macos_suffixes_313.clone(),
install_only_suffix: macos_install_only_suffix_313,
}],
},
);
Expand All @@ -100,6 +118,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13.0rc0").unwrap(),
suffixes: macos_suffixes_313.clone(),
install_only_suffix: macos_install_only_suffix_313,
}],
},
);
Expand All @@ -114,6 +133,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: vec!["freethreaded+pgo"],
install_only_suffix: "freethreaded+pgo",
}],
},
);
Expand All @@ -126,6 +146,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: vec!["freethreaded+pgo"],
install_only_suffix: "freethreaded+pgo",
}],
},
);
Expand All @@ -141,6 +162,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: vec!["freethreaded+pgo"],
install_only_suffix: "freethreaded+pgo",
}],
},
);
Expand All @@ -153,6 +175,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: vec!["freethreaded+pgo"],
install_only_suffix: "freethreaded+pgo",
}],
},
);
Expand All @@ -161,11 +184,13 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
let linux_suffixes_pgo = vec!["debug", "pgo+lto"];
let linux_suffixes_nopgo = vec!["debug", "lto", "noopt"];
let linux_suffixes_pgo_freethreaded = vec!["freethreaded+debug", "freethreaded+pgo+lto"];
let linux_install_only_suffixes_pgo_freethreaded = "freethreaded+pgo+lto";
let linux_suffixes_nopgo_freethreaded = vec![
"freethreaded+debug",
"freethreaded+lto",
"freethreaded+noopt",
];
let linux_install_only_suffixes_nopgo_freethreaded = "freethreaded+lto";

h.insert(
"aarch64-unknown-linux-gnu",
Expand All @@ -176,6 +201,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -189,6 +215,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -202,6 +229,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -215,6 +243,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -228,6 +257,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -241,6 +271,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_nopgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_nopgo_freethreaded,
}],
},
);
Expand All @@ -254,6 +285,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_pgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_pgo_freethreaded,
}],
},
);
Expand All @@ -266,6 +298,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_pgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_pgo_freethreaded,
}],
},
);
Expand All @@ -278,6 +311,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_pgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_pgo_freethreaded,
}],
},
);
Expand All @@ -290,6 +324,7 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
conditional_suffixes: vec![ConditionalSuffixes {
python_version_requirement: VersionSpecifier::from_str(">=3.13").unwrap(),
suffixes: linux_suffixes_pgo_freethreaded.clone(),
install_only_suffix: linux_install_only_suffixes_pgo_freethreaded,
}],
},
);
Expand Down Expand Up @@ -525,8 +560,18 @@ pub fn produce_install_only(tar_zst_path: &Path) -> Result<PathBuf> {
.map(|x| x.to_string())
.collect::<Vec<_>>();
let parts_len = name_parts.len();
let flavor_idx = parts_len - 2;

name_parts[parts_len - 2] = "install_only".to_string();
if name_parts[flavor_idx].contains("freethreaded") {
name_parts
.splice(
flavor_idx..flavor_idx + 1,
["freethreaded".to_string(), "install_only".to_string()],
)
.for_each(drop);
} else {
name_parts[flavor_idx] = "install_only".to_string();
}

let install_only_name = name_parts.join("-");
let install_only_name = install_only_name.replace(".tar.zst", ".tar.gz");
Expand Down