Use `@rules_python//python/runfiles` for examples and tests (#614)

Co-authored-by: Alex Eagle <eagle@post.harvard.edu>
diff --git a/examples/pip_parse/BUILD b/examples/pip_parse/BUILD
index d0f0529..43bd2f8 100644
--- a/examples/pip_parse/BUILD
+++ b/examples/pip_parse/BUILD
@@ -87,4 +87,5 @@
         "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("requests")),
         "YAMLLINT_ENTRY_POINT": "$(rootpath :yamllint)",
     },
+    deps = ["@rules_python//python/runfiles"],
 )
diff --git a/examples/pip_parse/WORKSPACE b/examples/pip_parse/WORKSPACE
index be1c8c7..986e4fb 100644
--- a/examples/pip_parse/WORKSPACE
+++ b/examples/pip_parse/WORKSPACE
@@ -1,4 +1,4 @@
-workspace(name = "example_repo")
+workspace(name = "rules_python_pip_parse_example")
 
 local_repository(
     name = "rules_python",
diff --git a/examples/pip_parse/pip_parse_test.py b/examples/pip_parse/pip_parse_test.py
index 8d8846a..6465fd6 100644
--- a/examples/pip_parse/pip_parse_test.py
+++ b/examples/pip_parse/pip_parse_test.py
@@ -5,6 +5,8 @@
 import unittest
 from pathlib import Path
 
+from rules_python.python.runfiles import runfiles
+
 
 class PipInstallTest(unittest.TestCase):
     maxDiff = None
@@ -13,11 +15,14 @@
         env = os.environ.get("YAMLLINT_ENTRY_POINT")
         self.assertIsNotNone(env)
 
-        entry_point = Path(env)
+        r = runfiles.Create()
+
+        # To find an external target, this must use `{workspace_name}/$(rootpath @external_repo//:target)`
+        entry_point = Path(r.Rlocation("rules_python_pip_parse_example/{}".format(env)))
         self.assertTrue(entry_point.exists())
 
         proc = subprocess.run(
-            [entry_point, "--version"],
+            [str(entry_point), "--version"],
             check=True,
             stdout=subprocess.PIPE,
             stderr=subprocess.PIPE,
@@ -38,7 +43,10 @@
         env = os.environ.get("SPHINX_BUILD_ENTRY_POINT")
         self.assertIsNotNone(env)
 
-        entry_point = Path(env)
+        r = runfiles.Create()
+
+        # To find an external target, this must use `{workspace_name}/$(rootpath @external_repo//:target)`
+        entry_point = Path(r.Rlocation("rules_python_pip_parse_example/{}".format(env)))
         self.assertTrue(entry_point.exists())
 
         proc = subprocess.run(