From 6e635c694ebf70bf7b6e26c0a9c0c95b803edb9b Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Thu, 10 Jul 2025 21:01:38 +0000 Subject: [PATCH 1/8] Updates (vendored) bleach to 6.2.0 and removes dependencies on `six` and `html5lib` Addresses #7010. The old version of bleach that we were using, needed dependencies `six` and `html5lib` to be installed, and the old version of "six" that we were using for CI via bazel is not supported in python >= 3.12, which causes some issues at least for local builds and CI when using newer versions of python. --- tensorboard/pip_package/build_pip_package.sh | 3 -- third_party/html5lib.BUILD | 54 -------------------- third_party/python.bzl | 28 ++-------- third_party/six.BUILD | 16 ------ third_party/workspace.bzl | 6 --- 5 files changed, 3 insertions(+), 104 deletions(-) delete mode 100644 third_party/html5lib.BUILD delete mode 100644 third_party/six.BUILD diff --git a/tensorboard/pip_package/build_pip_package.sh b/tensorboard/pip_package/build_pip_package.sh index ef8df0104dc..9c5cd945c81 100755 --- a/tensorboard/pip_package/build_pip_package.sh +++ b/tensorboard/pip_package/build_pip_package.sh @@ -86,15 +86,12 @@ build() ( mkdir -p tensorboard/_vendor >tensorboard/_vendor/__init__.py - cp -LR "${RUNFILES}/org_html5lib/html5lib" tensorboard/_vendor cp -LR "${RUNFILES}/org_mozilla_bleach/bleach" tensorboard/_vendor cp -LR "${RUNFILES}/org_pythonhosted_webencodings/webencodings" tensorboard/_vendor chmod -R u+w,go+r . find tensorboard -name \*.py -exec $sedi -e ' - s/^import html5lib$/from tensorboard._vendor import html5lib/ - s/^from html5lib/from tensorboard._vendor.html5lib/ s/^import bleach$/from tensorboard._vendor import bleach/ s/^from bleach/from tensorboard._vendor.bleach/ s/^import webencodings$/from tensorboard._vendor import webencodings/ diff --git a/third_party/html5lib.BUILD b/third_party/html5lib.BUILD deleted file mode 100644 index 24b448b00f0..00000000000 --- a/third_party/html5lib.BUILD +++ /dev/null @@ -1,54 +0,0 @@ -# Description: -# Import of html5lib library. - -load("@rules_python//python:py_library.bzl", "py_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # BSD-like notice-style license, see LICENSE file - -exports_files(["LICENSE"]) - -py_library( - name = "org_html5lib", - srcs = [ - "html5lib/__init__.py", - "html5lib/_ihatexml.py", - "html5lib/_inputstream.py", - "html5lib/_tokenizer.py", - "html5lib/_trie/__init__.py", - "html5lib/_trie/_base.py", - "html5lib/_trie/py.py", - "html5lib/_utils.py", - "html5lib/constants.py", - "html5lib/filters/__init__.py", - "html5lib/filters/alphabeticalattributes.py", - "html5lib/filters/base.py", - "html5lib/filters/inject_meta_charset.py", - "html5lib/filters/lint.py", - "html5lib/filters/optionaltags.py", - "html5lib/filters/sanitizer.py", - "html5lib/filters/whitespace.py", - "html5lib/html5parser.py", - "html5lib/serializer.py", - "html5lib/treeadapters/__init__.py", - "html5lib/treeadapters/genshi.py", - "html5lib/treeadapters/sax.py", - "html5lib/treebuilders/__init__.py", - "html5lib/treebuilders/base.py", - "html5lib/treebuilders/dom.py", - "html5lib/treebuilders/etree.py", - "html5lib/treebuilders/etree_lxml.py", - "html5lib/treewalkers/__init__.py", - "html5lib/treewalkers/base.py", - "html5lib/treewalkers/dom.py", - "html5lib/treewalkers/etree.py", - "html5lib/treewalkers/etree_lxml.py", - "html5lib/treewalkers/genshi.py", - ], - srcs_version = "PY3", - deps = [ - "@org_pythonhosted_six", - "@org_pythonhosted_webencodings", - ], -) diff --git a/third_party/python.bzl b/third_party/python.bzl index 8ac4a68c1c4..f64c5becaf6 100644 --- a/third_party/python.bzl +++ b/third_party/python.bzl @@ -44,25 +44,13 @@ def tensorboard_python_workspace(): build_file = str(Label("//third_party:urllib3.BUILD")), ) - http_archive( - name = "org_html5lib", - urls = [ - "http://mirror.tensorflow.org/github.com/html5lib/html5lib-python/archive/1.1.tar.gz", - "https://github.com/html5lib/html5lib-python/archive/1.1.tar.gz", - ], - sha256 = "66e9e24a53c10c27abb6be8a3cf2cf55824c6ea1cef8570a633cb223ec46e894", - strip_prefix = "html5lib-python-1.1", - build_file = str(Label("//third_party:html5lib.BUILD")), - ) - http_archive( name = "org_mozilla_bleach", urls = [ - "http://mirror.tensorflow.org/github.com/mozilla/bleach/archive/v2.0.tar.gz", - "https://github.com/mozilla/bleach/archive/v2.0.tar.gz", + "https://files.pythonhosted.org/packages/76/9a/0e33f5054c54d349ea62c277191c020c2d6ef1d65ab2cb1993f91ec846d1/bleach-6.2.0.tar.gz" ], - strip_prefix = "bleach-2.0", - sha256 = "789dcf3e7daf79c4c78518c6ebafd51bbaf111ac4263a97c08cf8d6a27eda820", + strip_prefix = "bleach-6.2.0", + sha256 = "123e894118b8a599fd80d3ec1a6d4cc7ce4e5882b1317a7e1ba69b56e95f991f", build_file = str(Label("//third_party:bleach.BUILD")), ) @@ -99,13 +87,3 @@ def tensorboard_python_workspace(): ], ) - http_archive( - name = "org_pythonhosted_six", - urls = [ - "http://mirror.tensorflow.org/pypi.python.org/packages/source/s/six/six-1.13.0.tar.gz", - "https://pypi.python.org/packages/source/s/six/six-1.13.0.tar.gz", - ], - sha256 = "30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66", - strip_prefix = "six-1.13.0", - build_file = str(Label("//third_party:six.BUILD")), - ) diff --git a/third_party/six.BUILD b/third_party/six.BUILD deleted file mode 100644 index 147193a0300..00000000000 --- a/third_party/six.BUILD +++ /dev/null @@ -1,16 +0,0 @@ -# Description: -# Six provides simple utilities for wrapping over differences between Python 2 -# and Python 3. - -load("@rules_python//python:py_library.bzl", "py_library") - -licenses(["notice"]) # MIT - -exports_files(["LICENSE"]) - -py_library( - name = "org_pythonhosted_six", - srcs = ["six.py"], - srcs_version = "PY3", - visibility = ["//visibility:public"], -) diff --git a/third_party/workspace.bzl b/third_party/workspace.bzl index afe0206f034..a4d268dce68 100644 --- a/third_party/workspace.bzl +++ b/third_party/workspace.bzl @@ -35,12 +35,6 @@ def tensorboard_workspace(name = ""): tensorboard_js_workspace() tensorboard_rust_workspace() - # Protobuf's BUILD file depends on //external:six. - native.bind( - name = "six", - actual = "@org_pythonhosted_six", - ) - # Needed by Protobuf. native.bind( name = "grpc_python_plugin", From 8fb57002888b40124c2747722470903b4291d13b Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Thu, 10 Jul 2025 22:22:35 +0000 Subject: [PATCH 2/8] Removes references to removed deps from bleach.BUILD --- third_party/bleach.BUILD | 5 ----- 1 file changed, 5 deletions(-) diff --git a/third_party/bleach.BUILD b/third_party/bleach.BUILD index ca5320933d8..98298ed2edc 100644 --- a/third_party/bleach.BUILD +++ b/third_party/bleach.BUILD @@ -21,9 +21,4 @@ py_library( "bleach/utils.py", "bleach/version.py", ], - srcs_version = "PY3", - deps = [ - "@org_html5lib", - "@org_pythonhosted_six", - ], ) From e3da543b3690f7678fa9e05f2acf736c96810386 Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Thu, 10 Jul 2025 22:27:59 +0000 Subject: [PATCH 3/8] Removes six from requirements.txt --- tensorboard/pip_package/requirements.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tensorboard/pip_package/requirements.txt b/tensorboard/pip_package/requirements.txt index 0cc39ff1ff6..27044df16d4 100644 --- a/tensorboard/pip_package/requirements.txt +++ b/tensorboard/pip_package/requirements.txt @@ -33,9 +33,5 @@ packaging # https://github.com/protocolbuffers/protobuf/issues/13485 protobuf >= 3.19.6, != 4.24.0 setuptools >= 41.0.0 # Note: provides pkg_resources as well as setuptools -# A dependency of our vendored packages. This lower bound has not been correctly -# vetted, but I wanted to be the least restrictive we can, since it's not a new -# requirement, and likely this will not disrupt existing users of the package. -six > 1.9 tensorboard-data-server >= 0.7.0, < 0.8.0 werkzeug >= 1.0.1 From 9f3f9f923d687db8903ce95b098705527d610685 Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Fri, 11 Jul 2025 00:56:31 +0000 Subject: [PATCH 4/8] Removes another reference to html5lib --- tensorboard/pip_package/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorboard/pip_package/BUILD b/tensorboard/pip_package/BUILD index 9e71cad7eff..bfa29d9a672 100644 --- a/tensorboard/pip_package/BUILD +++ b/tensorboard/pip_package/BUILD @@ -86,7 +86,6 @@ genrule( "@npm//:node_modules/d3/LICENSE", "@com_google_fonts_roboto//:LICENSE", "@org_mozilla_bleach//:LICENSE", - "@org_html5lib//:LICENSE", "@org_pythonhosted_webencodings//:LICENSE", "//third_party:bh_tsne.LICENSE", ], From d83eabb73fe7613694550e51652aad78e66c9906 Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Fri, 11 Jul 2025 01:37:51 +0000 Subject: [PATCH 5/8] Updates list of files required from bleach dependency --- third_party/bleach.BUILD | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/third_party/bleach.BUILD b/third_party/bleach.BUILD index 98298ed2edc..5679ab0fd0d 100644 --- a/third_party/bleach.BUILD +++ b/third_party/bleach.BUILD @@ -14,11 +14,8 @@ py_library( name = "org_mozilla_bleach", srcs = [ "bleach/__init__.py", - "bleach/callbacks.py", - "bleach/encoding.py", - "bleach/linkifier.py", + "bleach/html5lib_shim.py", + "bleach/parse_shim.py", "bleach/sanitizer.py", - "bleach/utils.py", - "bleach/version.py", ], ) From 4ee62ad750bae9333cbc7440a2cc8c94e186ba31 Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Fri, 11 Jul 2025 01:47:42 +0000 Subject: [PATCH 6/8] Updating the bleach dependency target again --- third_party/bleach.BUILD | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third_party/bleach.BUILD b/third_party/bleach.BUILD index 5679ab0fd0d..8415bb104b4 100644 --- a/third_party/bleach.BUILD +++ b/third_party/bleach.BUILD @@ -14,8 +14,12 @@ py_library( name = "org_mozilla_bleach", srcs = [ "bleach/__init__.py", + "bleach/callbacks.py", "bleach/html5lib_shim.py", + "bleach/linkifier.py", "bleach/parse_shim.py", "bleach/sanitizer.py", - ], + "bleach/six_shim.py", + ] + glob(["bleach/_vendor/**/*.py"]), + deps = ["@org_pythonhosted_webencodings"], ) From 8ad4b6aff128703f6f53cd90be4b04b3f151873d Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Fri, 11 Jul 2025 01:58:38 +0000 Subject: [PATCH 7/8] Removes unused dependency on bleach from text_plugin. Was refactored in #284 --- tensorboard/plugins/text/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorboard/plugins/text/BUILD b/tensorboard/plugins/text/BUILD index 8476737993b..b7aa4bedc8f 100644 --- a/tensorboard/plugins/text/BUILD +++ b/tensorboard/plugins/text/BUILD @@ -21,7 +21,6 @@ py_library( "//tensorboard/backend:http_util", "//tensorboard/data:provider", "//tensorboard/plugins:base_plugin", - "@org_mozilla_bleach", "@org_pocoo_werkzeug", "@org_pythonhosted_markdown", ], From 999609e0abb7b0aef830e8111c96e6a79bbaa1e9 Mon Sep 17 00:00:00 2001 From: Adrian RC Date: Fri, 11 Jul 2025 18:15:42 +0000 Subject: [PATCH 8/8] Add TF mirror url for bleach dependency --- third_party/python.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/python.bzl b/third_party/python.bzl index f64c5becaf6..a5a78698f57 100644 --- a/third_party/python.bzl +++ b/third_party/python.bzl @@ -47,6 +47,7 @@ def tensorboard_python_workspace(): http_archive( name = "org_mozilla_bleach", urls = [ + "http://mirror.tensorflow.org/files.pythonhosted.org/packages/76/9a/0e33f5054c54d349ea62c277191c020c2d6ef1d65ab2cb1993f91ec846d1/bleach-6.2.0.tar.gz", "https://files.pythonhosted.org/packages/76/9a/0e33f5054c54d349ea62c277191c020c2d6ef1d65ab2cb1993f91ec846d1/bleach-6.2.0.tar.gz" ], strip_prefix = "bleach-6.2.0",