33
44load ("//python:versions.bzl" , "TOOL_VERSIONS" , "get_release_info" )
55load ("//python/private:text_util.bzl" , "render" )
6+ load ("//python/private:version.bzl" , "version" )
67
78def print_toolchains_checksums (name ):
89 """A macro to print checksums for a particular Python interpreter version.
910
1011 Args:
1112 name: {type}`str`: the name of the runnable target.
1213 """
13- all_commands = []
1414 by_version = {}
1515
1616 for python_version , metadata in TOOL_VERSIONS .items ():
1717 by_version [python_version ] = _commands_for_version (
1818 python_version = python_version ,
1919 metadata = metadata ,
2020 )
21- all_commands .append (by_version [python_version ])
21+
22+ all_commands = sorted (
23+ by_version .items (),
24+ key = lambda x : version .key (version .parse (x [0 ], strict = True )),
25+ )
26+ all_commands = [x [1 ] for x in all_commands ]
2227
2328 template = """\
2429 cat > "$@" <<'EOF'
3742 srcs = [],
3843 outs = ["print_toolchains_checksums.sh" ],
3944 cmd = select ({
40- "//python/config_settings:is_python_{}" .format (version ): template .format (
45+ "//python/config_settings:is_python_{}" .format (version_str ): template .format (
4146 commands = commands ,
4247 )
43- for version , commands in by_version .items ()
48+ for version_str , commands in by_version .items ()
4449 } | {
4550 "//conditions:default" : template .format (commands = "\n " .join (all_commands )),
4651 }),
@@ -64,7 +69,7 @@ def _commands_for_version(*, python_version, metadata):
6469 "cat <<EOB" ,
6570 " \" {platform}\" : \" $$({get_sha256})\" ," .format (
6671 platform = platform ,
67- get_sha256 = "curl --location --fail {release_url_sha256} 2>/dev/null || curl --location --fail {release_url} 2>/dev/null | shasum -a 256 | awk '{{ print $$1 }}' " .format (
72+ get_sha256 = "curl --silent --show-error --location --fail {release_url_sha256} " .format (
6873 release_url = release_url ,
6974 release_url_sha256 = release_url + ".sha256" ,
7075 ),
0 commit comments