Skip to content

Refine ask‐option dependency resolution and strengthen tests #20033

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

Merged
merged 43 commits into from
Jun 26, 2025

Conversation

tyuwags
Copy link
Contributor

@tyuwags tyuwags commented May 31, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

These changes resolve an error a finding the whole hierarchy for the ask option, pruning the build dependencies and be able to find the whole dependants hierarchy of the formula.
These changes also create and update tests to make sure the whole hierarchy is displayed in the ask prompt.

@tyuwags
Copy link
Contributor Author

tyuwags commented May 31, 2025

I saw a problem, with this example, I don't know if it's the expected behaviour.
Here the deps of fonttools
fonttools
└── python@3.13
├── mpdecimal
├── openssl@3
│ └── ca-certificates
├── sqlite
│ └── readline
├── xz
└── expat
Fonttools and sqlite are outdated but not python@3.13
My function found correctly that if I do brew upgrade --ask fonttools that fonttools and sqlite need to be upgraded as I look into the recursive dependencies.
But as python@3.13 is up-to-date, sqlite isn't upgraded by brew, I don't know if it's a normal behaviour and I should modify my function in consequence or if I should open an issue for the upgrade function.

@tyuwags tyuwags reopened this Jun 1, 2025
@tyuwags tyuwags changed the title Fixing dependants and dependencies research in ask option and making tests stronger Refine ask‐option dependency resolution and strengthen tests Jun 1, 2025
@MikeMcQuaid
Copy link
Member

look into the recursive dependencies.
But as python@3.13 is up-to-date, sqlite isn't upgraded by brew, I don't know if it's a normal behaviour and I should modify my function in consequence or if I should open an issue for the upgrade function.

@tyuwags Not sure I understand the question. It's expected that some dependencies may need to be upgraded and others may not. Does that answer your question?

@tyuwags
Copy link
Contributor Author

tyuwags commented Jun 2, 2025

Thanks for the reply! Let me clarify the issue a bit:

In this example:

  • fonttools is outdated
  • sqlite is also outdated, and it's a dependency of python@3.13
  • python@3.13 itself is not outdated
    When I run brew upgrade --ask fonttools, my function detects both fonttools and sqlite as outdated by looking through recursive dependencies — which seems logical.

However, during the actual upgrade, Homebrew skips sqlite because its direct parent (python@3.13) is not being rebuilt.

So my actual question is:

Should my function consider only the outdated recursive dependencies whose parent will also be rebuilt?
Or is it fine (or even expected) that brew upgrade skips outdated indirect deps when their parent is not being upgraded?
I'm trying to align my implementation logic with how brew upgrade behaves internally. Thanks again!

@MikeMcQuaid
Copy link
Member

Or is it fine (or even expected) that brew upgrade skips outdated indirect deps when their parent is not being upgraded?

This is expected.

I'm trying to align my implementation logic with how brew upgrade behaves internally.

Thanks for this. Ideally this would be done by using the same code rather than having two code paths that have to mirror each other.

@tyuwags
Copy link
Contributor Author

tyuwags commented Jun 2, 2025

Thanks for this. Ideally this would be done by using the same code rather than having two code paths that have to mirror each other.

That was my initial thought as well. However, from what I’ve seen, brew doesn’t seem to know upfront which formulae will need to be upgraded. Instead, it determines the necessary dependencies and dependents dynamically using:

Upgrade.upgrade_formulae formulae_to_install
Upgrade.check_installed_dependents formulae_to_install

What I'd like is for these functions to return the full list of formulae that need to be upgraded, without performing the upgrade yet. Then, I could pass that list to a separate function that handles the actual upgrade logic.

This way, I could reuse the existing resolution logic and keep everything consistent, without duplicating or mirroring code paths.

@MikeMcQuaid
Copy link
Member

@tyuwags I'm open to seeing PR(s) to modify those functions to the logic can be shared. Let me know when this one is ready for review and maybe make it draft until then?

@tyuwags
Copy link
Contributor Author

tyuwags commented Jun 18, 2025

@MikeMcQuaid, everything is ready, everything is resolved

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

A few suggested style tweaks but the bulk of this looks great, thanks @tyuwags! Feel like we're really close now. Gonna ask a few other maintainers to review.

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Looks good overall. Mostly some naming comments here, though with a couple of logic comments at the end which are more important.

@MikeMcQuaid
Copy link
Member

Thanks @tyuwags!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jun 26, 2025
Merged via the queue into Homebrew:main with commit b87d288 Jun 26, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants