indygreg / python-build-standalone

Produce redistributable builds of Python
Mozilla Public License 2.0
1.98k stars 127 forks source link

What are the differences between the different versions of same tagged linux builds? #127

Closed konstin closed 2 years ago

konstin commented 2 years ago

I'd like to download the optimized linux x86_64 python 3.10 version that a user would like to have. On the 20220502 release page, I found:

Could you tell me what the differences between the default, _v2 and _v3 are, and ideally, what comes closest to what a typical user would expect as python 3.10?

indygreg commented 2 years ago

I added some documentation in commit bb3b3ba91bde0cfb7db53ef64f9bf99051ce60c7. You can see it published at https://python-build-standalone.readthedocs.io/en/latest/running.html.

Is the new documentation sufficient? Or do you think it still needs to be improved? (I could definitely see the need for a flowchart, matrix, or some other visual guide to steer people towards the right distribution...)

konstin commented 2 years ago

That's already perfect, thanks!

In case anyone else comes across the same problem, this is the regex i'm using for matching:

/// Returns a regex matching a compatible optimized build from the indygreg/python-build-standalone
/// release page.
///
/// https://python-build-standalone.readthedocs.io/en/latest/running.html
pub fn filename_regex(major: u8, minor: u8) -> Regex {
    let target_triple = target_lexicon::HOST.to_string();
    let target_triple = if target_triple.starts_with("x86_64-unknown-linux") {
        cpufeatures::new!(cpu_v3, "avx2");
        cpufeatures::new!(cpu_v2, "sse4.2");
        if cpu_v3::init().get() {
            target_triple.replace("x86_64", "x86_64_v3")
        } else if cpu_v2::init().get() {
            target_triple.replace("x86_64", "x86_64_v2")
        } else {
            target_triple
        }
    } else {
        target_triple
    };

    let version_re = format!(
        r#"^cpython-{major}\.{minor}\.(\d+)\+(\d+)-{target_triple}-pgo\+lto-full\.tar\.zst$"#,
        major = major,
        minor = minor,
        target_triple = regex::escape(&target_triple)
    );
    Regex::new(&version_re)
        .context("Failed to build version regex")
        .unwrap()
}

Featuring target-lexicon = "0.12.3" and regex = "1.5.5".

indygreg commented 2 years ago

Nice code snippet! Although I think you want to swap the order of the v2 and v3 tests since v3 is unlikely to be used if it is tested after v2.

konstin commented 2 years ago

oops you're right, thanks again!