title: How do I make a bazel `sh_binary` target depend on other binary targets?
body: <p>I have set up bazel to build a number of CLI tools that perform various database maintenance tasks.  Each one is a <code>py_binary</code> or <code>cc_binary</code> target that is called from the command line with the path to some data file: it processes that file and stores the results in a database.</p>
  
  <p>Now, I need to create a dependent package that contains data files and shell scripts that call these CLI tools to perform application-specific database operations.</p>
  
  <p>However, there doesn't seem to be a way to depend on the existing <code>py_binary</code> or <code>cc_binary</code> targets from a new package that only contains <code>sh_binary</code> targets and data files.  Trying to do so results in an error like:</p>
  
  <pre><code>ERROR: /workspace/shbin/BUILD.bazel:5:12: in deps attribute of sh_binary rule //shbin:run: py_binary rule '//pybin:counter' is misplaced here (expected sh_library)
  </code></pre>
  
  <p>Is there a way to call/depend on an existing bazel binary target from a shell script using <code>sh_binary</code>?</p>
  
  <p>I have implemented a full example here:
  <a href="https://github.com/psigen/bazel-mixed-binaries" rel="noreferrer">https://github.com/psigen/bazel-mixed-binaries</a></p>
  
  <hr>
  
  <p><strong>Notes:</strong></p>
  
  <p>I cannot use <code>py_library</code> and <code>cc_library</code> instead of <code>py_binary</code> and <code>cc_binary</code>. This is because <strong>(a)</strong> I need to call mixes of the two languages to process my data files and <strong>(b)</strong> these tools are from an upstream repository where they are already designed as CLI tools.</p>
  
  <p>I also cannot put all the data files into the CLI tool packages -- there are multiple application-specific packages and they cannot be mixed.</p>