Skip to content

Add installer hashes to info.json - #1327

Open
Jrice1317 wants to merge 17 commits into
conda:mainfrom
Jrice1317:hashes
Open

Add installer hashes to info.json#1327
Jrice1317 wants to merge 17 commits into
conda:mainfrom
Jrice1317:hashes

Conversation

@Jrice1317

@Jrice1317 Jrice1317 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Adds installer hashes to info.json so downstream tooling can use it as a single source of truth for installer checksums.

Changes:

  • Calculate requested installer hashes once and reuse them across build outputs.
  • Always include SHA256 in info.json; include additional algorithms requested by hash.
  • Refactor hash_files() to calculate multiple algorithms in one pass.
  • Preserve existing checksum file output.
  • Update schema, docs, and tests

Test expectations:

  • If only info.json is requested → expect SHA256 in _installer_hashes.
  • If only MD5 is requested → expect MD5 and the .md5 checksum file.
  • If both info.json and MD5 requested → expect SHA256 and MD5 to be calculated once and reused.
  • If neither is requested → expect no installer hashes to be calculated.
  • If multiple algorithms are requested → expect all hashes to be calculated in one pass.
  • If info.json and checksum files are generated → expect their hash values to match.
  • Existing SH installer MD5 behavior remains unchanged.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@github-project-automation github-project-automation Bot moved this to 🆕 New in 🔎 Review Aug 12, 2026
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Aug 12, 2026
@Jrice1317
Jrice1317 marked this pull request as ready for review August 13, 2026 02:23
@Jrice1317
Jrice1317 requested a review from a team as a code owner August 13, 2026 02:23
Comment thread constructor/data/construct.schema.json Outdated
"build_outputs": {
"default": [],
"description": "Additional artifacts to be produced after building the installer. It expects either a list of strings or single-key dictionaries.\nAllowed strings / keys: `hash`, `info.json`, `licenses`, `lockfile`, `pkgs_list`.",
"description": "Additional artifacts to be produced after building the installer. It expects either a list of strings or single-key dictionaries.\nRequesting `info.json` adds an `_installer_hashes` property containing the SHA256 digest of the generated installer. Hash algorithms requested through a `hash` build output are also included in this property.\nFor example:\n```json\n\"_installer_hashes\": {\n \"sha256\": \"...\",\n \"md5\": \"...\"\n}\n```\nThe `hash` output continues to create separate checksum files.\nAllowed strings / keys: `hash`, `info.json`, `licenses`, `lockfile`, `pkgs_list`.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we should not mention this here. I do think the information per say is good but as far as I can see we dont have any place right now explaining the contents of info.json - because of this it seems out of place.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I concur

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the whole thing or just the hardcoded example? I thought this was a good place because we do list info.json as an option in the schema here. However, I could see how my addition could be a little too detailed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd say remove the whole thing.

Comment thread constructor/build_outputs.py Outdated
Comment thread constructor/utils.py Outdated
algorithms = set(algorithms)
invalid = algorithms.difference(hashlib.algorithms_available)
if invalid:
raise ValueError(f"Invalid algorithm: {', '.join(sorted(invalid))}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These needs to be singular/plural based on len(invalid).

Comment thread constructor/utils.py
if invalid:
raise ValueError(f"Invalid algorithm: {', '.join(sorted(invalid))}")

BUFFER_SIZE = 65536

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whats the rationale here for changing to 64KB instead of 256KB (262144 below)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't change it. I only copied over what was already in build_outputs.py here. With that being said, if it should be changed to 262144 instead, then just let me know. 😃

Comment thread news/1327-installer-hashes-to-info-json Outdated
@@ -0,0 +1,19 @@
### Enhancements

* Add installer hashes to `info.json` making it the single source of truth for installer checksums used in SBOM generation. (#1327)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Add installer hashes to `info.json` making it the single source of truth for installer checksums used in SBOM generation. (#1327)
* Add installer hashes to `info.json` making it the single source of truth for installer checksums. (#1327)

I propose that we skip the last part since in theory users don't need to know the connection to SBOM generation.

Comment on lines +61 to +64
if isinstance(algorithm, str):
algorithms.add(algorithm)
elif algorithm:
algorithms.update(algorithm)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to validate that the hash algorithms are valid. It looks like that part of the code got removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It didn't get removed completely. It got moved here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, yes, thanks for pointing that out! It looks like the test catching that ValueError got removed though, so we are missing some test coverage.

outpath = Path(f"{installer}.{algo}")

with open(outpath, "w", newline="\n") as f:
f.write(f"{info['_installer_hashes'][algo]} {installer.name}\n")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should have a guard to make sure we don't have an uncaught exception here. That way, we can have a more meaningful error message.

Jrice1317 and others added 2 commits August 13, 2026 09:03
Co-authored-by: Robin <34315751+lrandersson@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

4 participants