missing input file ‘@tensorflow_pip//:libtensorflow_framework.so.1’

I am trying to build a tensorflow library from its github repo : https://github.com/tensorflow/compression, the instructions are available only for a TF1.15 version and the current master version has TF2.1 support which I need. I made some modifications to the example command https://github.com/tensorflow/compression#building-pip-packages and tried to build the pip package with the following command:

sudo docker run -v /tmp/tensorflow_compression:/tmp/tensorflow_compression tensorflow/tensorflow:custom-op-ubuntu16 bash -c "pip3 install --proxy=http://proxyaddr:port tensorflow==2.1.2 && pip3 install --proxy=http://proxyaddr:port tensorflow-probability==0.9.0 && mkdir /tensorflow_compression && git config --global http.proxy http://proxyaddr:port && git clone https://github.com/moha23/compression.git /tensorflow_compression &&
 cd /tensorflow_compression && export HTTPS_PROXY=http://proxyaddr:port && export HTTP_PROXY=http://proxyaddr:port &&
 bazel run -c opt --copt=-mavx :build_pip_pkg"

which throws the following error after installing everything and while running the bazel command:

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading: 0 packages loaded
Analyzing: target //:build_pip_pkg (1 packages loaded, 0 targets configured)
Analyzing: target //:build_pip_pkg (2 packages loaded, 1 target configured)
Analyzing: target //:build_pip_pkg (17 packages loaded, 18 targets configured)
Analyzing: target //:build_pip_pkg (22 packages loaded, 141 targets configured)
Analyzing: target //:build_pip_pkg (22 packages loaded, 141 targets configured)
INFO: Analyzed target //:build_pip_pkg (23 packages loaded, 2541 targets configured).
INFO: Found 1 target...
[0 / 6] [Prepa] Expanding template build_pip_pkg
ERROR: missing input file '@tensorflow_pip//:libtensorflow_framework.so.1'
ERROR: /root/.cache/bazel/_bazel_root/d5a5ee1fe6882ba2eee00312cabba7ca/external/tensorflow_pip/BUILD:2:1: @tensorflow_pip//:libtensorflow_framework: missing input file '@tensorflow_pip//:libtensorflow_framework.so.1'
Target //:build_pip_pkg failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /root/.cache/bazel/_bazel_root/d5a5ee1fe6882ba2eee00312cabba7ca/external/tensorflow_pip/BUILD:2:1 1 input file(s) do not exist
INFO: Elapsed time: 29.787s, Critical Path: 0.05s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully

I also tried running the docker container interactively and checking the folder /usr/local/lib/python3.6/dist-packages/tensorflow which has the file libtensorflow_framework.so.2. So I created a symlink ln -s libtensorflow_framework.so.2 libtensorflow_framework.so.1 and still the same error. Where is it looking for the file if not here?

I have never used bazel/docker and am at a total loss here, any help will be highly appreciated!


Adding the bazel workspace file code in case that helps:

"""WORKSPACE setup functions."""

def _tensorflow_pip_impl(ctx):
  python_program = ctx.which(ctx.attr.python_program)

  library_path = ctx.execute([
      "import tensorflow; print(tensorflow.sysconfig.get_lib())",
  include_path = ctx.execute([
      "import tensorflow; print(tensorflow.sysconfig.get_include())",

  if library_path.return_code != 0:
    fail("Failed to find library path. Did you remember to pip install " +
     "tensorflow?: %s" % library_path.stderr)
  if include_path.return_code != 0:
    fail("Failed to find include path. Did you remember to pip install " +
     "tensorflow?: %s" % include_path.stderr)

  if "linux" in ctx.os.name:
    library_filename = "libtensorflow_framework.so.1"
  elif "mac" in ctx.os.name:
    library_filename = "libtensorflow_framework.dylib"

  ctx.symlink("/".join([library_path.stdout.strip(), library_filename]),
  ctx.symlink(include_path.stdout.strip(), "include")
  ctx.file("BUILD", """
    name = "libtensorflow_framework",
    srcs = ["{0}"],
    hdrs = glob(["include/**"]),
    includes = ["include"],
    visibility = ["//visibility:public"],

tensorflow_pip = repository_rule(
    implementation = _tensorflow_pip_impl,
    attrs = {
        "python_program": attr.string(default = "python3"),

def tensorflow_compression_workspace():
      name = "tensorflow_pip",
      python_program = "python3",

Source: Docker Questions