-
Notifications
You must be signed in to change notification settings - Fork 541
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
feat(bzlmod): Adding base_url attr to python.toolchain #1216
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,27 @@ load("@rules_python//python/private:toolchains_repo.bzl", "get_host_os_arch", "g | |
def _python_impl(module_ctx): | ||
for mod in module_ctx.modules: | ||
for toolchain_attr in mod.tags.toolchain: | ||
python_register_toolchains( | ||
name = toolchain_attr.name, | ||
python_version = toolchain_attr.python_version, | ||
bzlmod = True, | ||
# Toolchain registration in bzlmod is done in MODULE file | ||
register_toolchains = False, | ||
register_coverage_tool = toolchain_attr.configure_coverage_tool, | ||
ignore_root_user_error = toolchain_attr.ignore_root_user_error, | ||
) | ||
if toolchain_attr.base_url: | ||
python_register_toolchains( | ||
name = toolchain_attr.name, | ||
python_version = toolchain_attr.python_version, | ||
bzlmod = True, | ||
# Toolchain registration in bzlmod is done in MODULE file | ||
register_toolchains = False, | ||
register_coverage_tool = toolchain_attr.configure_coverage_tool, | ||
ignore_root_user_error = toolchain_attr.ignore_root_user_error, | ||
base_url = toolchain_attr.base_url, | ||
) | ||
else: | ||
python_register_toolchains( | ||
name = toolchain_attr.name, | ||
python_version = toolchain_attr.python_version, | ||
bzlmod = True, | ||
# Toolchain registration in bzlmod is done in MODULE file | ||
register_toolchains = False, | ||
register_coverage_tool = toolchain_attr.configure_coverage_tool, | ||
ignore_root_user_error = toolchain_attr.ignore_root_user_error, | ||
) | ||
host_hub_name = toolchain_attr.name + "_host_interpreter" | ||
_host_hub( | ||
name = host_hub_name, | ||
|
@@ -44,6 +56,14 @@ python = module_extension( | |
tag_classes = { | ||
"toolchain": tag_class( | ||
attrs = { | ||
"base_url": attr.string( | ||
mandatory = False, | ||
doc = """\ | ||
The URL that is used to override rules_python DEFAULT_RELEASE_BASE_URL. This rule set downloads | ||
the different Python binaries from this website. Override this URL if you want to have rules_python | ||
download the hermetic versions of Python from a different website. | ||
""", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use the bazel downloader for this instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question! I asked the folks on #1172 to get their opinion. I think folks are using base_url, so if we are not going to support it people will have to migrate to this as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #1172 (comment) |
||
), | ||
"configure_coverage_tool": attr.bool( | ||
mandatory = False, | ||
doc = "Whether or not to configure the default coverage tool for the toolchains.", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickeylev not sure if there is a cleaner way to do this. If we don't set the base_url when we call python.toolchain, we end up with an empty string passed in. Then python_register_toolchains passes in an empty value to python_repository. We may have a weird use case where an empty URL is allowed; if not, I can test for an empty URL in python_register_toolchains, which is fewer lines of code.