Skip to content
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

Bzlmod: nodep deps #25280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Bzlmod: nodep deps #25280

wants to merge 1 commit into from

Conversation

Wyverald
Copy link
Member

This PR implements the "nodep" edges from https://docs.google.com/document/d/1JsfbH9kdMe3dyOY-IR8SUakS541A7OM8pQcKpxTRMRs/edit?tab=t.0, using the syntax of bazel_dep(..., repo_name=None). The behavior is that these edges are "unfulfilled" unless the module they refer to already exist in the dep graph by some other means.

Most of the changes are in the Discovery class -- I reorganized the code in there to hopefully help with readability, given the new multi-round discovery logic.

Also changed ModuleFileValue.Key to no longer take the applicable override next to the module key -- ModuleFileFunction now gets the root module from Skyframe itself and looks up the correct override. The old setup was always weird (what does it mean to request [email protected] with an incorrect override??).

Beyond that, I changed ModuleFileValue implementations to become records. Just for the heck of it.

Work towards #25214

PiperOrigin-RevId: 726734397
Change-Id: I1ca7a7a1228da5e4c2e4b5d6983a2ec97b31a4b8
@Wyverald Wyverald requested a review from fmeum February 14, 2025 04:00
@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Feb 14, 2025
doc =
"The name of the external repo representing this dependency. This is by default the"
+ " name of the module.",
+ " name of the module. If set to <code>None</code>, ",
Copy link
Member Author

Choose a reason for hiding this comment

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

oops... self reminder to write more here

Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

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

Nice!

"MODULE.bazel",
"""
bazel_dep(name='b',version='1.0')
bazel_dep(name='c',version='1.0',repo_name=None)
Copy link
Member

Choose a reason for hiding this comment

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

How does it interact with dev_dependency = True, should we add some test cases?

@fmeum
Copy link
Collaborator

fmeum commented Feb 14, 2025

The implementation looks good to me, but I wonder whether we could further minimize the impact of nodeps (assuming that there will be many, see boost). As it is, Bazel would still need to download and parse the module files of all nodeps modules some version of which is contained in the dep graph.

If we didn't have compatibility_level, we wouldn't have to fetch nodeps whose version compares less or equal to a module version that's already in the dep graph, knowing that they couldn't possibly become relevant. Maybe we can relax the handling of nodeps somewhat to still get this behavior? For example, we could specify that A with a nodep on B 1.0 (compatibility level 1) and B with a regular dep on B 2.0 (compatibility level 2) would not result in a build failure, but rather select B 2.0.

I am bringing this up now since changing it later would be a breaking change.

}

@Test
public void nodep_crossesCompatLevelBoundary() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a test for a fulfilled no-dep that crosses a compat level boundary (and thus causes the build to fail)?

@Wyverald
Copy link
Member Author

For example, we could specify that A with a nodep on B 1.0 (compatibility level 1) and B with a regular dep on B 2.0 (compatibility level 2) would not result in a build failure, but rather select B 2.0.

That's already the case IIUC -- the A->B1.0 edge is not examined during selection, so we never notice the existence of B1.0. (It's the same as the A-regular->B1.0 and B-nodep->B2.0 case)

@fmeum
Copy link
Collaborator

fmeum commented Feb 15, 2025

I see. In that case, how about making it so that we don't even fetch the module file of B1.0 during discovery? In any case, could you add assertions on the registry files fetched during discovery to the unit tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants