|
16 | 16 | """ |
17 | 17 |
|
18 | 18 | load("//python/private:platform_info.bzl", "platform_info") |
19 | | -load("//python/private:text_util.bzl", "render") |
20 | 19 |
|
21 | 20 | # Values present in the @platforms//os package |
22 | 21 | MACOS_NAME = "osx" |
@@ -441,88 +440,6 @@ def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_U |
441 | 440 |
|
442 | 441 | return (release_filename, rendered_urls, strip_prefix, patches, patch_strip) |
443 | 442 |
|
444 | | -def print_toolchains_checksums(name): |
445 | | - """A macro to print checksums for a particular Python interpreter version. |
446 | | -
|
447 | | - Args: |
448 | | - name: {type}`str`: the name of the runnable target. |
449 | | - """ |
450 | | - all_commands = [] |
451 | | - by_version = {} |
452 | | - |
453 | | - for python_version, metadata in TOOL_VERSIONS.items(): |
454 | | - by_version[python_version] = _commands_for_version( |
455 | | - python_version = python_version, |
456 | | - metadata = metadata, |
457 | | - ) |
458 | | - all_commands.append(by_version[python_version]) |
459 | | - |
460 | | - template = """\ |
461 | | -cat > "$@" <<'EOF' |
462 | | -#!/bin/bash |
463 | | -
|
464 | | -set -o errexit -o nounset -o pipefail |
465 | | -
|
466 | | -echo "Fetching hashes..." |
467 | | -
|
468 | | -{commands} |
469 | | -EOF |
470 | | - """ |
471 | | - |
472 | | - native.genrule( |
473 | | - name = name, |
474 | | - srcs = [], |
475 | | - outs = ["print_toolchains_checksums.sh"], |
476 | | - cmd = select({ |
477 | | - "//python/config_settings:is_python_{}".format(version): template.format( |
478 | | - commands = commands, |
479 | | - ) |
480 | | - for version, commands in by_version.items() |
481 | | - } | { |
482 | | - "//conditions:default": template.format(commands = "\n".join(all_commands)), |
483 | | - }), |
484 | | - executable = True, |
485 | | - ) |
486 | | - |
487 | | -def _commands_for_version(*, python_version, metadata): |
488 | | - lines = [] |
489 | | - lines += [ |
490 | | - "cat <<EOB", # end of block |
491 | | - " \"{python_version}\": {{".format(python_version = python_version), |
492 | | - " \"url\": \"{url}\",".format(url = metadata["url"]), |
493 | | - " \"sha256\": {", |
494 | | - ] |
495 | | - |
496 | | - for platform in metadata["sha256"].keys(): |
497 | | - for release_url in get_release_info(platform, python_version)[1]: |
498 | | - # Do lines one by one so that the progress is seen better and use cat for ease of quotation |
499 | | - lines += [ |
500 | | - "EOB", |
501 | | - "cat <<EOB", |
502 | | - " \"{platform}\": \"$$({get_sha256})\",".format( |
503 | | - platform = platform, |
504 | | - 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( |
505 | | - release_url = release_url, |
506 | | - release_url_sha256 = release_url + ".sha256", |
507 | | - ), |
508 | | - ), |
509 | | - ] |
510 | | - |
511 | | - prefix = metadata["strip_prefix"] |
512 | | - prefix = render.indent( |
513 | | - render.dict(prefix) if type(prefix) == type({}) else repr(prefix), |
514 | | - indent = " " * 8, |
515 | | - ).lstrip() |
516 | | - |
517 | | - lines += [ |
518 | | - " },", |
519 | | - " \"strip_prefix\": {strip_prefix},".format(strip_prefix = prefix), |
520 | | - " },", |
521 | | - "EOB", |
522 | | - ] |
523 | | - |
524 | | - return "\n".join(lines) |
525 | | - |
526 | 443 | def gen_python_config_settings(name = ""): |
527 | 444 | for platform in PLATFORMS.keys(): |
528 | 445 | native.config_setting( |
|
0 commit comments