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

Bzlmod: Support local_path in Bazel Registry's source.json file #16319

Closed
meteorcloudy opened this issue Sep 21, 2022 · 0 comments
Closed

Bzlmod: Support local_path in Bazel Registry's source.json file #16319

meteorcloudy opened this issue Sep 21, 2022 · 0 comments
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@meteorcloudy
Copy link
Member

meteorcloudy commented Sep 21, 2022

Currently the source.json (e.g. for grpc) file in a Bazel registry only accepts attributes that can be translated to a http_archive repository rule, Bazel then delegates the fetching of the Bazel module to the http_archive rule.

But when users try to set up their own Bazel registry, they might want to point a Bazel module to a different path that hosts the source of the Bazel module (instead of an archive). Therefore, it would be useful to support other types of repositories in the source.json file, and an attribute 'type' to differentiate between them.

Supported types:
'archive' : the default value if no type was provided
'local_path'

E.g.

{
    "type": "local_path",
    "path": "/Users/foo/bar/project_x"
}
{
    "type": "local_path",
    "path": "../foo/bar/project_y"
}

For the second case where path is a relative path, we need to decide which path it should be relative to.
To solve this we can add a module_base_path in the bazel_registry.json file of the registry.

Then we resolve path by the following rules:

  1. If path is already an absolute path, then just use it.
  2. If path is a relative path and module_base_path is an absolute path, then path is resolved to <module_base_path>/<path>
  3. If path and module_base_path are both relative paths, then path is resolved to <registry_path>/<module_base_path>/<path>.

Note that in the 3rd case, we need to parse registry_path from the registry URL, which means the registry must be hosted locally and used by --registry=file://<registry_path> (instead of https://). Otherwise, Bazel should throw an error.

@meteorcloudy meteorcloudy added type: feature request P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Sep 21, 2022
@meteorcloudy meteorcloudy added this to the 6.0.0 release blockers milestone Sep 21, 2022
@SalmaSamy SalmaSamy changed the title Bzlmod: Support local_repository in Bazel Registry's source.json file Bzlmod: Support local_path in Bazel Registry's source.json file Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants