Allow other mirrors in tf_http_archive(urls) and move check to macro so it gets evaluated even if the external repository is not used.
PiperOrigin-RevId: 359592620 Change-Id: I0c17e164f3f29f0fd0334f88a2192a97c5284e51
This commit is contained in:
parent
35b5b4228d
commit
855c4c0ee3
22
third_party/repo.bzl
vendored
22
third_party/repo.bzl
vendored
@ -34,14 +34,6 @@ def _get_link_dict(ctx, link_files, build_file):
|
||||
return {ctx.path(v): Label(k) for k, v in link_files.items()}
|
||||
|
||||
def _tf_http_archive_impl(ctx):
|
||||
# if len(ctx.attr.urls) < 2 or "mirror.tensorflow.org" not in ctx.attr.urls[0]:
|
||||
if False: # TODO(b/174771515): fix call sites and enable check again.
|
||||
fail("tf_http_archive(urls) must have redundant URLs. The " +
|
||||
"mirror.tensorflow.org URL must be present and it must come first. " +
|
||||
"Even if you don't have permission to mirror the file, please " +
|
||||
"put the correctly formatted mirror URL there anyway, because " +
|
||||
"someone will come along shortly thereafter and mirror the file.")
|
||||
|
||||
# Construct all labels early on to prevent rule restart. We want the
|
||||
# attributes to be strings instead of labels because they refer to files
|
||||
# in the TensorFlow repository, not files in repos depending on TensorFlow.
|
||||
@ -98,6 +90,20 @@ def tf_http_archive(name, sha256, urls, **kwargs):
|
||||
labels (e.g. '@foo//:bar') or from a label created in their repository (e.g.
|
||||
'str(Label("//:bar"))').
|
||||
"""
|
||||
if len(urls) < 2:
|
||||
fail("tf_http_archive(urls) must have redundant URLs.")
|
||||
|
||||
if not any([mirror in urls[0] for mirror in (
|
||||
"mirror.tensorflow.org",
|
||||
"mirror.bazel.build",
|
||||
"storage.googleapis.com",
|
||||
)]):
|
||||
fail("The first entry of tf_http_archive(urls) must be a mirror " +
|
||||
"URL, preferrably mirror.tensorflow.org. Even if you don't have " +
|
||||
"permission to mirror the file, please put the correctly " +
|
||||
"formatted mirror URL there anyway, because someone will come " +
|
||||
"along shortly thereafter and mirror the file.")
|
||||
|
||||
if native.existing_rule(name):
|
||||
print("\n\033[1;33mWarning:\033[0m skipping import of repository '" +
|
||||
name + "' because it already exists.\n")
|
||||
|
Loading…
Reference in New Issue
Block a user