Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: register
mock
dependency with Bazel
Summary: We’ve heretofore used the `mock` library without telling Bazel about it. This isn’t generally a problem when `tensorflow` is installed in the same virtualenv, because `tensorflow` pulls in `mock`. But tests that don’t depend on TensorFlow have no build edge to `mock` when imported into google3’s build system, causing build failures after syncing. This commit makes the `mock` dependency explict. We use `mock==1.0.0` rather than the current version (2.0.0) because the current version depends on `pbr` at runtime in a way that does not play well with Bazel: <testing-cabal/mock#383> (It appears to be trying to find some globally registered `setup.cfg` file from which to read a version identifier.) Rather than vendoring and patching `mock`, declaring a fake `:expect_mock_installed` target, or hacking `PBR_VERSION=2.0.0` into the action env, we simply depend on a saner version of the library, which is also the version used in google3. Existing `mock` users have been detected and fixed up: ``` $ bazel query " > kind( > py_.*rule, > rdeps(//..., set($(git grep -l 'import mock\($\| \)')), 1) > ) > " \ > | awk '{ print "add deps @org_pythonhosted_mock|" $0 }' \ > | buildozer -f - \ > ; ``` Test Plan: All notf tests now pass in a virtualenv that does not include `mock`: ``` $ virtualenv -q -p python2 ./ve $ . ./ve/bin/activate (ve) $ pip install 'absl-py>=0.7.0' 'numpy<2.0,>=1.14.5' boto3==1.9.86 flake8==3.5.0 futures==3.1.1 grpcio==1.6.3 yamllint==1.5.0 >/dev/null 2>&1 (ve) $ python -c 'import mock' Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/local/buildtools/current/sitecustomize/sitecustomize.py", line 152, in SetupPathsAndImport return real_import(name, globals, locals, fromlist, level) ImportError: No module named mock (ve) $ cd ~/git/tensorboard (ve) $ bazel test //tensorboard/... --test_tag_filters=support_notf ... INFO: Build completed successfully, 12 total actions //tensorboard:lazy_test PASSED in 0.2s //tensorboard:lib_test PASSED in 0.9s //tensorboard:manager_test PASSED in 0.3s //tensorboard:plugin_util_test PASSED in 0.5s //tensorboard:program_test PASSED in 0.8s //tensorboard/backend:application_test PASSED in 1.0s //tensorboard/backend:http_util_test PASSED in 0.8s //tensorboard/backend:json_util_test PASSED in 0.8s //tensorboard/compat/tensorflow_stub:gfile_test PASSED in 0.8s //tensorboard/summary:summary_test PASSED in 0.8s //tensorboard/util:platform_util_test PASSED in 0.3s ``` Previously, `manager_test` and `application_test` failed in such an environment. wchargin-branch: mock-dep
- Loading branch information