Skip to content

Expose YARN_VERSION and YARN_SHA256#110

Open
Darshan808 wants to merge 5 commits into
jupyterlab:mainfrom
Darshan808:expose-yarn-version
Open

Expose YARN_VERSION and YARN_SHA256#110
Darshan808 wants to merge 5 commits into
jupyterlab:mainfrom
Darshan808:expose-yarn-version

Conversation

@Darshan808

@Darshan808 Darshan808 commented May 24, 2026

Copy link
Copy Markdown
Member

Fixes #105

Description

Expose Yarn version from the vendored yarn.js at import time and also compute and expose its SHA256 hash.

Currently, the generated hash matches the upstream Yarn 3.5.0 release. Once PR #109 is merged, the bundled yarn.js will diverge, and the hash will become specific to Jupyter Builder rather than any standard Yarn release.

@Darshan808 Darshan808 added the enhancement New feature or request label May 24, 2026
@Darshan808 Darshan808 requested a review from bollwyvl May 24, 2026 08:59
@Darshan808 Darshan808 marked this pull request as ready for review May 24, 2026 08:59
Comment on lines +14 to +22
# Minified yarn berry embeds the version as: YarnVersion:()=>VarName ... var VarName="x.y.z"
_match = re.search(rb"YarnVersion:\(\)=>(\w+)", _yarn_bytes)
if _match:
_var = re.escape(_match.group(1))
_match = re.search(rb"var " + _var + rb'="([^"]+)"', _yarn_bytes)

if not _match:
msg = "Could not extract YARN_VERSION from vendored yarn.js"
raise RuntimeError(msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks a bit fragile, I think a minimum countermeasure would be adding a test case for this.

@fleming79 fleming79 left a comment

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.

Some comments for consideration.

from pathlib import Path

_yarn_js = Path(__file__).resolve().parent / "yarn.js"
_yarn_bytes = _yarn_js.read_bytes()

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.

Consider deleting this when it is no longer required as it takes significant memory to store.

msg = "Could not extract YARN_VERSION from vendored yarn.js"
raise RuntimeError(msg)

YARN_VERSION: str = _match.group(1).decode()

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 recommend storing the version and hash as constants and comparing the hash instead with an assertion. If the hash hasn't changed, the version will be correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Todo
Status: No status

Development

Successfully merging this pull request may close these issues.

Expose version of vendored yarn

3 participants