title: Bazel: Make genrule outputs available to another rule
body: <p>I need the outputs of a <code>genrule</code> to be available <strong>next to</strong> another rule. (i.e. a <code>py_binary</code>).</p>
  
  <p>Suppose we have these files:</p>
  
  <pre class="lang-py prettyprint-override"><code># root/gen/BUILD:
  genrule(
    name = "gen",
    outs = ["a.txt", "a2.txt"],
    cmd = "cd $(RULEDIR) &amp;&amp; echo salam &gt; a.txt &amp;&amp; echo hello &gt; a2.txt",
  )
  
  # root/BUILD:
  py_binary(
    name = "use",
    srcs = ["use.py"],
    data = ["gen:a.txt", "gen:a2.txt"],
  )
  
  # use.py:
  f = open("a.txt", "r")
  f2 = open("a2.txt", "r")
  print(f.read())
  print(f2.read())
  
  </code></pre>
  
  <p>At a glance:</p>
  
  <pre><code>project
  ├── root
  │   ├── BUILD
  │   ├── gen
  │   │   └── BUILD  &lt;&lt; This can generate required 'a.txt' and 'a2.txt' 
  |   |                 files.
  │   └── use.py  &lt;&lt; This script needs to access a.txt file as './a.txt',
  |                  but with 'bazel run root:use' it should access files
  |                  like 'root/gen/a.txt'.
  └── WORKSPACE
  </code></pre>
  
  <p>When I run <code>bazel run :use</code>, it doesn't find the file:</p>
  
  <pre><code>FileNotFoundError: [Errno 2] No such file or directory: 'a.txt'
  </code></pre>
  
  <p>It needs to have <code>a.txt</code> and <code>a2.txt</code> files <strong>nearby</strong>, but they are in <code>bazel-bin/gen</code> directory.</p>