-
-
Notifications
You must be signed in to change notification settings - Fork 14
Use additional npm / Yarn options to speed up installation #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,25 +94,27 @@ def npm_builder( | |
| if isinstance(npm, str): | ||
| npm = [npm] | ||
|
|
||
| is_yarn = (abs_path / "yarn.lock").exists() | ||
|
|
||
| # Find a suitable default for the npm command. | ||
| if npm is None: | ||
| is_yarn = (abs_path / "yarn.lock").exists() | ||
| if is_yarn and not which("yarn"): | ||
| log.warning("yarn not found, ignoring yarn.lock file") | ||
| is_yarn = False | ||
|
|
||
| npm = ["yarn"] if is_yarn else ["npm"] | ||
|
|
||
| npm_cmd = normalize_cmd(npm) | ||
|
|
||
| install_cmd = ["install", "--immutable"] if is_yarn else ["install", "--no-audit", "--no-fund"] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be reasonable to use However, Do we care more about absolute correctness or speed when building internal JS assets for a Python package?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wary of changing any of this default behavior, as I'm not a JS developer anymore and I'm not sure what affect this would have on existing consumers.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, are you comfortable with this change as-is?
|
||
|
|
||
| if build_dir and source_dir and not force: | ||
| should_build = is_stale(build_dir, source_dir) | ||
| else: | ||
| should_build = True | ||
|
|
||
| if should_build: | ||
| log.info("Installing build dependencies with npm. This may take a while...") | ||
| run([*npm_cmd, "install"], cwd=str(abs_path)) | ||
| run([*npm_cmd, *install_cmd], cwd=str(abs_path)) | ||
| if build_cmd: | ||
| run([*npm_cmd, "run", build_cmd], cwd=str(abs_path)) | ||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always been possible that this heuristic is incorrect, but the risk is slightly magnified now that we rely on it even if
npm(the executable location) is explicitly provided.I don't see a better alternative though, without attempting to look within
npmto do pattern-matching for"yarn", which could still be incorrect (e.g.npm = "/home/john.yarn/bin/npm").There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically this change is what I am uncertain about.