I'm writing some validation code for a bazel build rule and I need to do some path validation. I need to check that a certain file exists in the same directory as the BUILD file. I notice that there's a context attribute build_file_path
which points to the BUILD file. I'd like to extract the parent directory from this.
It looks like I can't create a new path
object - I don't see a constructor/initializer. It also seems like Starlark doesn't support os.path
like python because imports aren't supported.
What's the canonical way to get the parent directory of a string object representing a path in Starlark?