10000 fix(toolchain): set correct return attrs to remove non-hermeticity wa… · Rasrack/rules_python@07e6856 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07e6856

Browse files
authored
fix(toolchain): set correct return attrs to remove non-hermeticity warning (bazel-contrib#1231)
Fixes the incorrect debug statement when downloading the toolchain for the first time asking users to replace "urls" with "url" in the toolchain definition which we maintain: ``` $ bazel build ... ... indicated that a canonical reproducible form can be obtained by modifying ... ``` Even though this is seen only once by the user, it may confuse them. Summary of changes: - refactor(toolchain): rename a local variable url -> urls - fix(toolchain): set url return attrs correctly
1 parent 16126d0 commit 07e6856

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

python/repositories.bzl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ def _python_repository_impl(rctx):
106106
python_version = rctx.attr.python_version
107107
python_short_version = python_version.rpartition(".")[0]
108108
release_filename = rctx.attr.release_filename
109-
url = rctx.attr.urls or [rctx.attr.url]
109+
urls = rctx.attr.urls or [rctx.attr.url]
110110

111111
if release_filename.endswith(".zst"):
112112
rctx.download(
113-
url = url,
113+
url = urls,
114114
sha256 = rctx.attr.sha256,
115115
output = release_filename,
116116
)
@@ -153,7 +153,7 @@ def _python_repository_impl(rctx):
153153
fail(fail_msg)
154154
else:
155155
rctx.download_and_extract(
156-
url = url,
156+
url = urls,
157157
sha256 = rctx.attr.sha256,
158158
stripPrefix = rctx.attr.strip_prefix,
159159
)
@@ -348,7 +348,7 @@ py_runtime_pair(
348348
rctx.file(STANDALONE_INTERPRETER_FILENAME, "# File intentionally left blank. Indicates that this is an interpreter repo created by rules_python.")
349349
rctx.file("BUILD.bazel", build_content)
350350

351-
return {
351+
attrs = {
352352
"coverage_tool": rctx.attr.coverage_tool,
353353
"distutils": rctx.attr.distutils,
354354
"distutils_content": rctx.attr.distutils_content,
@@ -360,9 +360,15 @@ py_runtime_pair(
360360
"release_filename": release_filename,
361361
"sha256": rctx.attr.sha256,
362362
"strip_prefix": rctx.attr.strip_prefix,
363-
"url": url,
364363
}
365364

365+
if rctx.attr.url:
366+
attrs["url"] = rctx.attr.url
367+
else:
368+
attrs["urls"] = urls
369+
370+
return attrs
371+
366372
python_repository = repository_rule(
367373
_python_repository_impl,
368374
doc = "Fetches the external tools needed for the Python toolchain.",

0 commit comments

Comments
 (0)
0