diff --git a/.travis.yml b/.travis.yml index 070d97d84b..0a37740366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,7 +102,6 @@ install: - pip install flake8==3.5.0 - pip install futures==3.1.1 - pip install grpcio==1.6.3 - - pip install mock==2.0.0 - pip install moto==1.3.7 - pip install yamllint==1.5.0 - | diff --git a/tensorboard/BUILD b/tensorboard/BUILD index 6af3f23c2c..19d49bae6f 100644 --- a/tensorboard/BUILD +++ b/tensorboard/BUILD @@ -83,6 +83,7 @@ py_test( ":test", ":version", "//tensorboard/util:tb_logging", + "@org_pythonhosted_mock", "@org_pythonhosted_six", ], ) @@ -101,6 +102,7 @@ py_test( deps = [ ":manager", "//tensorboard:expect_tensorflow_installed", + "@org_pythonhosted_mock", "@org_pythonhosted_six", ], data = [ diff --git a/tensorboard/backend/BUILD b/tensorboard/backend/BUILD index 318b94372f..66afa8118a 100644 --- a/tensorboard/backend/BUILD +++ b/tensorboard/backend/BUILD @@ -90,6 +90,7 @@ py_test( "//tensorboard/backend/event_processing:event_multiplexer", "//tensorboard/plugins:base_plugin", "@org_pocoo_werkzeug", + "@org_pythonhosted_mock", ], ) diff --git a/tensorboard/plugins/hparams/BUILD b/tensorboard/plugins/hparams/BUILD index eefb1183ae..67c40c667d 100644 --- a/tensorboard/plugins/hparams/BUILD +++ b/tensorboard/plugins/hparams/BUILD @@ -61,6 +61,7 @@ py_test( "//tensorboard:expect_tensorflow_installed", "//tensorboard/backend/event_processing:event_accumulator", "//tensorboard/backend/event_processing:event_multiplexer", + "@org_pythonhosted_mock", ], ) @@ -73,6 +74,7 @@ py_test( deps = [ ":hparams_plugin", "//tensorboard:expect_tensorflow_installed", + "@org_pythonhosted_mock", ], ) @@ -87,6 +89,7 @@ py_test( "//tensorboard:expect_tensorflow_installed", "//tensorboard/backend/event_processing:event_accumulator", "//tensorboard/backend/event_processing:event_multiplexer", + "@org_pythonhosted_mock", ], ) diff --git a/tensorboard/plugins/interactive_inference/BUILD b/tensorboard/plugins/interactive_inference/BUILD index ce0a616978..cbba5d47c1 100644 --- a/tensorboard/plugins/interactive_inference/BUILD +++ b/tensorboard/plugins/interactive_inference/BUILD @@ -39,6 +39,7 @@ py_test( "//tensorboard/plugins/interactive_inference/utils:platform_utils", "//tensorboard/plugins/interactive_inference/utils:test_utils", "@org_pocoo_werkzeug", + "@org_pythonhosted_mock", "@org_pythonhosted_six", ], ) diff --git a/tensorboard/plugins/interactive_inference/utils/BUILD b/tensorboard/plugins/interactive_inference/utils/BUILD index 4204d69d09..f83ae69350 100644 --- a/tensorboard/plugins/interactive_inference/utils/BUILD +++ b/tensorboard/plugins/interactive_inference/utils/BUILD @@ -53,6 +53,7 @@ py_test( ":test_utils", "//tensorboard:expect_numpy_installed", "//tensorboard:expect_tensorflow_installed", + "@org_pythonhosted_mock", "@org_tensorflow_serving_api", ], ) diff --git a/third_party/mock.BUILD b/third_party/mock.BUILD new file mode 100644 index 0000000000..841af364cd --- /dev/null +++ b/third_party/mock.BUILD @@ -0,0 +1,15 @@ +# Description: +# Rolling backport of unittest.mock for all Pythons + +licenses(["notice"]) # MIT + +exports_files(["LICENSE"]) + +py_library( + name = "org_pythonhosted_mock", + srcs = [ + "mock.py", + ], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/python.bzl b/third_party/python.bzl index ab5aeb8d92..1f1b604ea7 100644 --- a/third_party/python.bzl +++ b/third_party/python.bzl @@ -76,6 +76,23 @@ def tensorboard_python_workspace(): build_file = str(Label("//third_party:werkzeug.BUILD")), ) + # We use `mock==1.0.0` because later versions depend on `pbr`, which + # doesn't work well in a hermetic context (it tries to look up some + # global configuration files; see GitHub pull request #2132). + # + # This dependency can go away entirely once we drop Python 2 support + # and can just depend on `unittest.mock`. + http_archive( + name = "org_pythonhosted_mock", + urls = [ + "https://mirror.bazel.build/files.pythonhosted.org/packages/85/60/ec8c1af81337bab0caba188b218b6758bc94f125f49062f7c5f0647749d2/mock-1.0.0.tar.gz", + "https://files.pythonhosted.org/packages/85/60/ec8c1af81337bab0caba188b218b6758bc94f125f49062f7c5f0647749d2/mock-1.0.0.tar.gz", + ], + sha256 = "2d9fbe67001d2e8f02692075257f3c11e1b0194bd838c8ce3f49b31fc6c3f033", + strip_prefix = "mock-1.0.0", + build_file = str(Label("//third_party:mock.BUILD")), + ) + http_archive( name = "org_pythonhosted_six", urls = [