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

Allow module extension usages to be isolated #18529

Closed
wants to merge 5 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented May 30, 2023

If isolate = True is specified on use_extension, that particular usage will be isolated from all other usages, both in the same and other modules.

Module extensions can check whether they are isolated (e.g. in case they can only be used in this way) via module_ctx.is_isolated.

@fmeum fmeum force-pushed the isolated branch 4 times, most recently from 4d34d12 to c816feb Compare May 30, 2023 14:21
Copy link
Contributor

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

I like this idea. I think this would help with the distinction between globally unified and local packages in rules_nixpkgs, see here. The globally unified ones would be provided by a regular extension, and the local ones by an isolated extension.

@fmeum
Copy link
Collaborator Author

fmeum commented Jun 9, 2023

I added tests as well as module_ctx.extension_metadata support. I also changed the naming scheme, see the comment in BazelDepGraphFunction.

@Wyverald bazelbuild/buildtools#1171 is the corresponding change to buildozer.

@fmeum fmeum marked this pull request as ready for review June 9, 2023 19:32
@fmeum fmeum requested a review from meteorcloudy as a code owner June 9, 2023 19:32
@fmeum fmeum requested a review from Wyverald June 9, 2023 19:33
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. labels Jun 9, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 10, 2023

Gson doesn't seem to handle Optional<T> out of the box. @SalmaSamy Do you happen to know what the best approach is to manually add support for it?

Edit: I found a way, but it's rather verbose.

@fmeum fmeum force-pushed the isolated branch 4 times, most recently from c83e00e to 23291be Compare June 11, 2023 19:57
@SalmaSamy
Copy link
Contributor

SalmaSamy commented Jun 12, 2023

Do you happen to know what the best approach is to manually add support for it?

Unfortunately not. Probably writing an adapter for it, though you will still need to handle the object type somehow Ex: via TypeToken or something.

@fmeum
Copy link
Collaborator Author

fmeum commented Jun 12, 2023

I ended up writing my own TypeAdapterFactory: 23291be

Copy link
Member

@Wyverald Wyverald left a comment

Choose a reason for hiding this comment

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

nice!

If `isolated = True` is specified on `use_extension`, that particular
usage will be isolated from all other usages, both in the same and other
modules.

Module extensions can check whether they are isolated (e.g. in case they
can only be used in this way) via `module_ctx.is_isolated`.
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 15, 2023

Just in case you missed it: I changed the name of the parameter from isolated to isolate as I felt that matches better with use_extension. Let me know if you don't like this "bikeshe" :-)

@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jun 15, 2023
@fmeum fmeum deleted the isolated branch June 20, 2023 08:48
@sgowroji sgowroji removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jun 20, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 20, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Jun 20, 2023
@meteorcloudy
Copy link
Member

@bazel-io fork 6.3.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Jun 20, 2023
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Jun 20, 2023
If `isolate = True` is specified on `use_extension`, that particular usage will be isolated from all other usages, both in the same and other modules.

Module extensions can check whether they are isolated (e.g. in case they can only be used in this way) via `module_ctx.is_isolated`.

Closes bazelbuild#18529.

PiperOrigin-RevId: 541823020
Change-Id: I68a7b49914bbc1fd50df2fda7a0af1e47421bb92
iancha1992 added a commit that referenced this pull request Jun 21, 2023
If `isolate = True` is specified on `use_extension`, that particular usage will be isolated from all other usages, both in the same and other modules.

Module extensions can check whether they are isolated (e.g. in case they can only be used in this way) via `module_ctx.is_isolated`.

Closes #18529.

PiperOrigin-RevId: 541823020
Change-Id: I68a7b49914bbc1fd50df2fda7a0af1e47421bb92

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
aherrmann added a commit to tweag/rules_nixpkgs that referenced this pull request Sep 29, 2023
This uses the new isolated module extensions feature [1], instead of a
hub-repository approach [2] [3], to distinguish globally unified
repositories and locally specialized repositories.

[1]: bazelbuild/bazel#18529
[2]: bazelbuild/bazel#17048
[3]: bazelbuild/bazel#17493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants