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

Bazel: Support local_path_override #8810

Closed
nnobelis opened this issue Jun 28, 2024 · 1 comment
Closed

Bazel: Support local_path_override #8810

nnobelis opened this issue Jun 28, 2024 · 1 comment
Labels
analyzer About the analyzer tool enhancement Issues that are considered to be enhancements

Comments

@nnobelis
Copy link
Member

The user can specify that a dependency should come from a certain directory on local disk.
See https://bazel.build/rules/lib/globals/module#local_path_override.

Example in MODULE.bazel:

local_path_override(
    module_name = "locator",
    path = "./tools/bazelbuild/modules/locator",
)

ORT should support this alternate locations for downloading the source code.

@haikoschol FYI

@nnobelis nnobelis added enhancement Issues that are considered to be enhancements to triage Issues that need triaging labels Jun 28, 2024
@sschuberth sschuberth added analyzer About the analyzer tool and removed to triage Issues that need triaging labels Aug 13, 2024
@nnobelis
Copy link
Member Author

Supporting this feature seems to be a bit tricky.

Bazel does provide some of the override information in the build file:

"localOverrideHashes": {
   "test_module": "0444b4db8c556a0c4e2fbf7407f3f9c1b9a1733dc872776daa8df2678470d146",
   "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787"
 },

BUT:

  • This information has been removed from the lock file starting from the version 7.2.0: https://bazel.build/versions/7.2.0/external/lockfile (compare the versions using the selector top right)
  • Even if we implement fetching the override information using the lock file, this would provide us only the module_name part above and we would still be lacking the path part.

I asked the Bazel's Slack channel if there were alternative to parsing the MODULE.bazel file ourselves.
They suggested using the buildozer tool instead (https://github.com/bazelbuild/buildtools/blob/main/buildozer/README.md#buildozer) with a command such as:
buildozer 'print module_name path' //MODULE.bazel:%local_path_override

It sorts of work but there is a bug with it:
bazelbuild/buildtools#1286

They recommended a workaround but I find it a bit hackish. Any opinion ?

nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
nnobelis added a commit to boschglobal/oss-review-toolkit that referenced this issue Aug 19, 2024
Local path overrides are dependencies for which the sourcecode comes from
the project repository (see [1]). Since the information relative to these
overrides is not present in the Bazel lock file, it has to be extracted
from the MODULE.basel file instead. To achieve the latter, this commit uses
the tool `buildozer`.

Fixes oss-review-toolkit#8810.

[1]: https://bazel.build/rules/lib/globals/module#local_path_override

Signed-off-by: Nicolas Nobelis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer About the analyzer tool enhancement Issues that are considered to be enhancements
Projects
None yet
Development

No branches or pull requests

2 participants