runfiles: Remove dead code (#1011)
Runfiles discovery relative to `argv[0]` isn't used as that logic lives
in the launcher.
diff --git a/python/runfiles/runfiles.py b/python/runfiles/runfiles.py
index 01413fc..9bdb61b 100644
--- a/python/runfiles/runfiles.py
+++ b/python/runfiles/runfiles.py
@@ -366,56 +366,3 @@
# pick up RUNFILES_DIR.
"JAVA_RUNFILES": self._runfiles_root,
}
-
-
-def _PathsFrom(
- argv0, runfiles_mf, runfiles_dir, is_runfiles_manifest, is_runfiles_directory
-):
- # type: (str, str, str, Callable[[str], bool], Callable[[str], bool]) -> Tuple[str, str]
- """Discover runfiles manifest and runfiles directory paths.
-
- Args:
- argv0: string; the value of sys.argv[0]
- runfiles_mf: string; the value of the RUNFILES_MANIFEST_FILE environment
- variable
- runfiles_dir: string; the value of the RUNFILES_DIR environment variable
- is_runfiles_manifest: lambda(string):bool; returns true if the argument is
- the path of a runfiles manifest file
- is_runfiles_directory: lambda(string):bool; returns true if the argument is
- the path of a runfiles directory
-
- Returns:
- (string, string) pair, first element is the path to the runfiles manifest,
- second element is the path to the runfiles directory. If the first element
- is non-empty, then is_runfiles_manifest returns true for it. Same goes for
- the second element and is_runfiles_directory respectively. If both elements
- are empty, then this function could not find a manifest or directory for
- which is_runfiles_manifest or is_runfiles_directory returns true.
- """
- mf_alid = is_runfiles_manifest(runfiles_mf)
- dir_valid = is_runfiles_directory(runfiles_dir)
-
- if not mf_alid and not dir_valid:
- runfiles_mf = argv0 + ".runfiles/MANIFEST"
- runfiles_dir = argv0 + ".runfiles"
- mf_alid = is_runfiles_manifest(runfiles_mf)
- dir_valid = is_runfiles_directory(runfiles_dir)
- if not mf_alid:
- runfiles_mf = argv0 + ".runfiles_manifest"
- mf_alid = is_runfiles_manifest(runfiles_mf)
-
- if not mf_alid and not dir_valid:
- return ("", "")
-
- if not mf_alid:
- runfiles_mf = runfiles_dir + "/MANIFEST"
- mf_alid = is_runfiles_manifest(runfiles_mf)
- if not mf_alid:
- runfiles_mf = runfiles_dir + "_manifest"
- mf_alid = is_runfiles_manifest(runfiles_mf)
-
- if not dir_valid:
- runfiles_dir = runfiles_mf[:-9] # "_manifest" or "/MANIFEST"
- dir_valid = is_runfiles_directory(runfiles_dir)
-
- return (runfiles_mf if mf_alid else "", runfiles_dir if dir_valid else "")
diff --git a/tests/runfiles/runfiles_test.py b/tests/runfiles/runfiles_test.py
index 966d012..9fa2a18 100644
--- a/tests/runfiles/runfiles_test.py
+++ b/tests/runfiles/runfiles_test.py
@@ -505,134 +505,6 @@
r.Rlocation("config.json", "protobuf~3.19.2"), dir + "/config.json"
)
- def testPathsFromEnvvars(self):
- # Both envvars have a valid value.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "mock1/MANIFEST",
- lambda path: path == "mock2",
- )
- self.assertEqual(mf, "mock1/MANIFEST")
- self.assertEqual(dr, "mock2")
-
- # RUNFILES_MANIFEST_FILE is invalid but RUNFILES_DIR is good and there's a
- # runfiles manifest in the runfiles directory.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "mock2/MANIFEST",
- lambda path: path == "mock2",
- )
- self.assertEqual(mf, "mock2/MANIFEST")
- self.assertEqual(dr, "mock2")
-
- # RUNFILES_MANIFEST_FILE is invalid but RUNFILES_DIR is good, but there's no
- # runfiles manifest in the runfiles directory.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: False,
- lambda path: path == "mock2",
- )
- self.assertEqual(mf, "")
- self.assertEqual(dr, "mock2")
-
- # RUNFILES_DIR is invalid but RUNFILES_MANIFEST_FILE is good, and it is in
- # a valid-looking runfiles directory.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "mock1/MANIFEST",
- lambda path: path == "mock1",
- )
- self.assertEqual(mf, "mock1/MANIFEST")
- self.assertEqual(dr, "mock1")
-
- # RUNFILES_DIR is invalid but RUNFILES_MANIFEST_FILE is good, but it is not
- # in any valid-looking runfiles directory.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "mock1/MANIFEST",
- lambda path: False,
- )
- self.assertEqual(mf, "mock1/MANIFEST")
- self.assertEqual(dr, "")
-
- # Both envvars are invalid, but there's a manifest in a runfiles directory
- # next to argv0, however there's no other content in the runfiles directory.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "argv0.runfiles/MANIFEST",
- lambda path: False,
- )
- self.assertEqual(mf, "argv0.runfiles/MANIFEST")
- self.assertEqual(dr, "")
-
- # Both envvars are invalid, but there's a manifest next to argv0. There's
- # no runfiles tree anywhere.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "argv0.runfiles_manifest",
- lambda path: False,
- )
- self.assertEqual(mf, "argv0.runfiles_manifest")
- self.assertEqual(dr, "")
-
- # Both envvars are invalid, but there's a valid manifest next to argv0, and
- # a valid runfiles directory (without a manifest in it).
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "argv0.runfiles_manifest",
- lambda path: path == "argv0.runfiles",
- )
- self.assertEqual(mf, "argv0.runfiles_manifest")
- self.assertEqual(dr, "argv0.runfiles")
-
- # Both envvars are invalid, but there's a valid runfiles directory next to
- # argv0, though no manifest in it.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: False,
- lambda path: path == "argv0.runfiles",
- )
- self.assertEqual(mf, "")
- self.assertEqual(dr, "argv0.runfiles")
-
- # Both envvars are invalid, but there's a valid runfiles directory next to
- # argv0 with a valid manifest in it.
- mf, dr = runfiles._PathsFrom(
- "argv0",
- "mock1/MANIFEST",
- "mock2",
- lambda path: path == "argv0.runfiles/MANIFEST",
- lambda path: path == "argv0.runfiles",
- )
- self.assertEqual(mf, "argv0.runfiles/MANIFEST")
- self.assertEqual(dr, "argv0.runfiles")
-
- # Both envvars are invalid and there's no runfiles directory or manifest
- # next to the argv0.
- mf, dr = runfiles._PathsFrom(
- "argv0", "mock1/MANIFEST", "mock2", lambda path: False, lambda path: False
- )
- self.assertEqual(mf, "")
- self.assertEqual(dr, "")
-
def testCurrentRepository(self):
# This test assumes that it is running without --enable_bzlmod as the
# correct result with Bzlmod would be the empty string - the canonical