Suppose I have the following BUILD
file
py_library(
name = "foo",
src = ["foo.py"],
data = ["//bar:data.json"],
)
How should I refer to the data.json
in foo.py
file? I wanted to have something like below, what should I use for some_path
?
with open(os.path.join(some_path, "bar/data.json"), 'r') as fp:
data = json.load(fp)
I couldn't find much general documentation about *.runfiles
online -- any pointer will be appreciated!
For the benefit of others who find there way here, the canonical solution is to use the provided "runfiles" library provided by the
rules_python
package for bazel.In my environment, it looks roughly like this:
More documentation can be found here: