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

Don't fail when override is called from a non-root module #2550

Open
mailto-jonas opened this issue Jan 8, 2025 · 0 comments
Open

Don't fail when override is called from a non-root module #2550

mailto-jonas opened this issue Jan 8, 2025 · 0 comments

Comments

@mailto-jonas
Copy link

🐞 bug report

Affected Rule

The error is in pypi module extension when using the override tag class. See attached patch for location.

The issue is caused by the rule:

Non-root modules are failing to load.

Is this a regression?

This has never worked since the introduction of bzlmod.

Description

I have a Bazel module that I use in two different setup, where it in the first scenario acts as the root module and in the second scenario it is exported and used as a non-root module. The module is using rules_python and needs to apply a pip patch using the override tag class. However, in the current implementation, rules_python does not allow any calls to override when non-root, leading to a failure. Since there is no support for selects of if-cases within the MODULE.bazel file, this behavior prevents the second setup described above.

It would be beneficial if rules_python would trigger a warning instead of failing, to support the above use cases.

🔬 Minimal Reproduction

Add the following code to a non root module:
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.override()

🔥 Exception or Error

The module extension calls: fail("overrides are only supported in root modules")

🌍 Your Environment

Ubuntu 22.04
Bazel 8.0.0
rules_python 1.0.0
non_root_override.patch.txt

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

No branches or pull requests

1 participant