-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Refactor some dependency handling to fix various API dependency issues #15566
Conversation
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.
Looking good so far!
My main concern is the migration path for API consumers here and avoiding making API consumers having to rewrite their code for a change that none of them having really complained about.
Somewhat relatedly: I've been thinking for a little while that I think there could be benefit in a JSON output/API subset that is strictly what we need and not what API consumers do. Now that we have formula.jws.json
and cask.jws.json
: I 100% guarantee that no-one except us is decoding and using these files except us so they seem like a very good candidate for slimming down API fields to the bare minimum that we need/consume to make those files smaller.
For other cases e.g. brew info --json
output and the formula.json
files: I'm tempted to say we don't deprecate those old fields and just leave them around indefinitely. They aren't really size-sensitive and not breaking our (pretty much unversioned) public APIs is much more appealing than slimming down these files.
Thanks again for the PR!
Will have a look at this PR later, but since we're looking at refactoring dependency handling: Some of the "auto" dependencies (e.g. |
Thanks for reminding me. I knew there was another reason for tagging those dependencies as this wasn't the first time I had the idea to do that but I had forgotten what that other reason was. |
Agreed 👍🏻
🎉 |
fd411c2 will probably handle this (untested). Though that won't necesssarily stop opportunistic linkage from simply being installed, should any formula do that - but that's not specific to implicit dependencies. The change should however stop it from being added to the superenv variables. |
fb7642e
to
3af8b41
Compare
73d3ecc
to
3b2df10
Compare
@Bo98 been following along with this but just FYI I'll hold off another proper review until it's non-draft. Feel free to nudge me in Slack if I miss that! |
828654a
to
44ea6fb
Compare
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.
Looks great, thanks again @Bo98!
Library/Homebrew/dependency.rb
Outdated
raise ArgumentError, "Dependency must have a name!" unless name | ||
|
||
@name = name | ||
@tags = tags | ||
@env_proc = env_proc | ||
@option_names = option_names | ||
|
||
@tap = Tap.fetch(name.rpartition("/").first) if name.match?(HOMEBREW_TAP_FORMULA_REGEX) |
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.
Not blocking: given how often we do this all over the place: feels like we should have a better accessor for this sort of thing.
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.
Probably.
I've tweaked this slightly in the meantime to:
@tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2)) if name =~ HOMEBREW_TAP_FORMULA_REGEX
Add Formula#declared_deps and SoftwareSpec#declared_deps
This PR tries to tackle several of the "harder" issues involving API dependencies. Basically the stuff that required deeper refactoring rather than a hack-on fix.
There were several cases where the dependency list was incorrect. Usually this erred on the side of too many dependencies rather than too little, so hasn't seen widespread bug reports beyond a few comments here and there.
Notably:
uses_from_macos "example", since: ...
did not work correctly.This changes in this PR are:
TapDependency
(this makes the rest of the PR a bit simpler), folding it intoDependency
uses_from_macos
handling. Instead of being a conditionaldepends_on
, it now consistently adds aUsesFromMacOSDependency
on all platforms with the checks now taking place ininstalled?
. This provides a more consistent behaviour on all platforms, and has a bonus of reducing the bloat of thevariations
part of the JSON.auto
tag, which is now applied to all dependencies not explicitly added via adepends_on
. This fixes an issue where some of the "if needed" deps leaked from the machine that generated the API JSON. For example, if a formula usesxz
and the machine that generated the API JSON did not havexz
, it will now no longer appear on the API dependency list and instead be determined by the API consumer.This is draft because rspec tests need adjusting and basic commands are probably very broken as is. But the general implementation as a whole should be done, with just bug/typo fixes needed.