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

Do not announce platform repos as module dependencies #763

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

Conversation

mering
Copy link
Contributor

@mering mering commented Jan 17, 2025

Fixes #727

@thesayyn
Copy link
Collaborator

There is not much we could do about this; we have to report what can imported by the module, and that includes platform specific repos as well.

If bazel had a way to let us tell it what can be imported, then we could use that instead.

@mering
Copy link
Contributor Author

mering commented Jan 20, 2025

There is not much we could do about this; we have to report what can imported by the module, and that includes platform specific repos as well.

If bazel had a way to let us tell it what can be imported, then we could use that instead.

Bazel already knows what can be imported: all repos generated by the extension. This is also how it calculates the indirect dependencies (all generated ones minus the direct ones).
The information about direct dependencies is used by bazel mod tidy to automatically update the use_repo() call.

Is there any use case of using the platform specific repos over the general one (which use the platform specific ones as indirect dependency)?

@thesayyn
Copy link
Collaborator

Bazel already knows what can be imported: all repos generated by the extension

right, sorry.

Is there any use case of using the platform specific repos

Yes, if you want to build an image for a specific architecture without using transitions, eg you want to build a python image, and don't want to use transitions to get correct base image.

So instead of base = "@base", you use @base_linux_amd64, that's why we report these platform specific repos for tidy.

@mering
Copy link
Contributor Author

mering commented Jan 20, 2025

Is there any use case of using the platform specific repos

Yes, if you want to build an image for a specific architecture without using transitions, eg you want to build a python image, and don't want to use transitions to get correct base image.

So instead of base = "@base", you use @base_linux_amd64, that's why we report these platform specific repos for tidy.

This only works when using pure Python without any FFI pip dependencies, right?

Maybe it might be better not to report anything? I think the currently state is quite bad.

In one repo the platform specific stuff is added which we don't need and which confuses people. In the other repo we want to use the same (version of) a base image from another repo. There it is reported as indirect dependency and gets removed and breaks our build. So if there is no good way for the extension to determine which imports should be used, maybe leave it to be always manually specified by the user?

@thesayyn
Copy link
Collaborator

This only works when using pure Python without any FFI pip dependencies, right?

Yes, but python is just an example, nodejs, java all can work on any platform similar to python, so we need to report these.

I don't understand exactly how this is creating a problem for you.

Right here we report deps if the extension was called from from the root module, so you shouldn't see any warnings from "other" repos, also we always add these to direct dependencies.

deps = root_direct_dev_deps if module_ctx.is_dev_dependency(pull) else root_direct_deps

As for the confusion part, as i said there is no way for the extension to know what you import and don't, there we can't conditionally report platform specific ones, what we need is bazel supporting auto removal of use_repo calls reported by the extension if they are not used anywhere in the repo. Its confusing for you use case to have these use_repo calls, it is also confusing to not have them, that's why we added them in the first place.

See when this was introduced and discussion around it #611

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.

Bzlmod doesn't detect repo usage correctly
2 participants