Skip to content

Add support for Bazel MODULE.bazel module manifests (fixes #4123)#4806

Open
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
kumarasantosh:add-bazel-module-support
Open

Add support for Bazel MODULE.bazel module manifests (fixes #4123)#4806
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
kumarasantosh:add-bazel-module-support

Conversation

@kumarasantosh
Copy link
Copy Markdown
Contributor

Adds BazelModuleHandler to parse MODULE.bazel files (Bzlmod format).

  • Extracts name and version from module()
  • Extracts all bazel_dep() entries with dev vs runtime scoping
  • Uses pkg:bazel/name@version PURLs
  • Includes test fixture and passing tests

Closes #4123

@kumarasantosh kumarasantosh force-pushed the add-bazel-module-support branch from dae779f to 5c27c08 Compare March 11, 2026 14:36
…r to parse MODULE.bazel manifests

- Parses module() for name and version
- Parses bazel_dep() including dev_dependency flag
- Adds test fixture and test cases

Fixes aboutcode-org#4123

Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
Copy link
Copy Markdown
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

@kumarasantosh thanks, see comments and general comments from the review at #4803 (review), some major changes required.

Comment thread src/packagedcode/build.py
default_package_type = 'bazel'
description = 'Bazel BUILD'
documentation_url = 'https://bazel.build/'
datasource_id = "bazel_build"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add examples of codebases where bazel build and module manifests are both present together and how the functionality handles both together, and merging through assembly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/packagedcode/build.py
)
return get_mapping_and_expression_from_detections(license_detections=license_detections)


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are also MODULE.bazel.lock files we need to handle https://github.com/google/allocation-instrumenter/blob/master/MODULE.bazel.lock

Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
@kumarasantosh kumarasantosh force-pushed the add-bazel-module-support branch from 53085a6 to 6cfd5e4 Compare April 15, 2026 15:36
@kumarasantosh
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @AyanSinhaMahapatra . I’ve addressed the Bazel feedback—added MODULE.bazel.lock support, improved assembly to merge module files, included a real-world fixture, and added end-to-end tests to verify detection and merging. Please take another look when you have time.

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.

Support Bazel modules

2 participants