Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

remove dependency on external python for sha256 #1993

Merged
merged 3 commits into from
Jan 26, 2022

Conversation

dragonsinth
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

^^ unsure if this is necessary; existing tests probably cover?

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

sha256 computation depends on https://github.com/bazelbuild/bazel/tree/master/tools/build_defs/hash which requires external python. We can replace this with a simple Go cmd.

Issue Number: #1555

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

if err := ioutil.WriteFile(os.Args[2], []byte(hexSum), 0666); err != nil {
log.Fatalf("error writing %s: %s", os.Args[2], err)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executable = True,
allow_files = True,
),
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing to that, it's a strange API shape in this file, but I think it's clever how you made it a drop-in replacement.

@dragonsinth dragonsinth changed the title remove dependency on external python remove dependency on external python for sha256 Jan 9, 2022
@dragonsinth
Copy link
Contributor Author

@alexeagle sorry to ping.. I wasn't sure if I'm supposed to do something to make anyone aware I opened this. :)

Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some nits, thanks for fixing this! I agree with the reasoning in the linked issue.

executable = True,
allow_files = True,
),
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing to that, it's a strange API shape in this file, but I think it's clever how you made it a drop-in replacement.

skylib/hash.bzl Outdated
@@ -0,0 +1,23 @@
"""Functions for producing the hash of an artifact."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment here pointing to the upstream hash.bzl in bazel_tools and explain why we forked it? that way we have a chance of comparing this against future changes to that one.

@@ -87,7 +87,7 @@ A rule that imports a docker image into our intermediate form.
| <a id="container_import-layers"></a>layers | The list of layer .tar.gz files in the order they appear in the config.json's layer section, or in the order that they appear in the <code>Layers</code> field of the docker save tarballs' <code>manifest.json</code> (these may or may not be gzipped).<br><br> Note that the layers should each have a different basename. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
| <a id="container_import-manifest"></a>manifest | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="container_import-repository"></a>repository | - | String | optional | "bazel" |
| <a id="container_import-sha256"></a>sha256 | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //tools/build_defs/hash:sha256 |
| <a id="container_import-sha256"></a>sha256 | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //container/go/cmd/sha256:sha256 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funny how the old doc here was wrong since it didn't include the repository name

@@ -0,0 +1,39 @@
// Portable SHA256 tool.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a comment here about the sha256.py you mentioned below so we have a chance of finding it later.

@dragonsinth
Copy link
Contributor Author

@alexeagle thanks! Addressed the feedback.

@dragonsinth
Copy link
Contributor Author

Ping :D

@alexeagle alexeagle merged commit 9096572 into bazelbuild:master Jan 26, 2022
@dragonsinth dragonsinth deleted the gohash branch February 4, 2022 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants