Skip to content

Commit

Permalink
Make the module extension more user-friendly. (#56)
Browse files Browse the repository at this point in the history
This is a followup to a post-merge comment on the preceding commit:
#55 (comment)
  • Loading branch information
junyer authored Aug 11, 2023
1 parent af7151f commit fd7d888
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions python_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,13 @@ def _parse_my_own_version_from_module_dot_bazel(ctx):
def _extension_impl(ctx):
toolchain = None
for module in ctx.modules:
if module.is_root:
if not module.tags.toolchain:
pass
elif len(module.tags.toolchain) == 1:
toolchain = module.tags.toolchain[0]
else:
_fail("The root module may not specify multiple `toolchain` " +
"tags. Found %r `toolchain` tags specified." % (
len(module.tags.toolchain),
))
elif module.tags.toolchain:
_fail("A non-root module may not specify any `toolchain` tags. " +
"Found %r `toolchain` tags specified by module %r." % (
len(module.tags.toolchain),
module.name,
))
if not module.is_root or not module.tags.toolchain:
continue
toolchain = module.tags.toolchain[0]
if len(module.tags.toolchain) >= 2:
print("The root module specified two or more `toolchain` tags. " +
"Using only the first of %r `toolchain` tags specified." % (
len(module.tags.toolchain)))
if toolchain == None:
python_configure(
name = "local_config_python",
Expand Down

0 comments on commit fd7d888

Please sign in to comment.