Lines Matching +full:get +full:- +full:caller +full:- +full:file
4 # you may not use this file except in compliance with the License.
7 # http://www.apache.org/licenses/LICENSE-2.0
15 """Runfiles lookup library for Bazel-built Python binaries and tests.
31 # type: (str) -> _Runfiles
36 # type: (str) -> _Runfiles
41 # type: (Optional[Dict[str, str]]) -> Optional[_Runfiles]
45 - manifest-based, meaning it looks up runfile paths from a manifest file, or
46 - directory-based, meaning it looks up runfile paths under a given directory
49 If `env` contains "RUNFILES_MANIFEST_FILE" with non-empty value, this method
50 returns a manifest-based implementation. The object eagerly reads and caches
51 the whole manifest file upon instantiation; this may be relevant for
54 Otherwise, if `env` contains "RUNFILES_DIR" with non-empty value (checked in
55 this priority order), this method returns a directory-based implementation.
66 manifest = env_map.get("RUNFILES_MANIFEST_FILE")
70 directory = env_map.get("RUNFILES_DIR")
80 Runfiles are data-dependencies of Bazel-built binaries and tests.
84 # type: (Union[_ManifestBased, _DirectoryBased]) -> None
92 # type: (str, Optional[str]) -> Optional[str]
95 Runfiles are data-dependencies of Bazel-built binaries and tests.
97 The returned path may not be valid. The caller should check the path's
100 The function may return None. In that case the caller can be sure that the
101 rule does not know about this data-dependency.
104 path: string; runfiles-root-relative path of the runfile
108 repository mapping of the repository containing the caller of this
113 the path to the runfile, which the caller should check for existence, or
138 # Look up runfiles using the repository mapping of the caller of the
148 # - not using Bzlmod, so the repository mapping is empty and
150 # - target_repo is already a canonical repository name and does not
152 # - path did not contain a slash and referred to a root symlink,
163 # type: () -> Dict[str, str]
166 The caller should set the returned key-value pairs in the environment of
167 subprocesses in case those subprocesses are also Bazel-built binaries that
177 # type: (int) -> str
178 """Returns the canonical name of the caller's Bazel repository.
187 https://bazel.build/build/bzlmod#repository-names
190 runfiles the caller is located to determine which repository it came
192 caller is, for example if it is not represented by a Python source
193 file. Use the `frame` argument to control the stack lookup.
197 Defaults to 1, the caller of the CurrentRepository function.
200 The canonical name of the Bazel repository containing the file
201 containing the frame-th caller of this function
204 ValueError: if the caller cannot be determined or the caller's file
207 # pylint:disable=protected-access # for sys._getframe
208 # pylint:disable=raise-missing-from # we're still supporting Python 2
212 raise ValueError("failed to determine caller's file path")
237 # type: () -> str
241 # the current file is being run. This path coincides with what the Bazel
250 # type: (Optional[str]) -> Dict[Tuple[str, str], str]
252 # If the repository mapping file can't be found, that is not an error: We
275 """`Runfiles` strategy that parses a runfiles-manifest to look up runfiles."""
278 # type: (str) -> None
287 # type: (str) -> Optional[str]
289 exact_match = self._runfiles.get(path)
298 prefix_end = path.rfind("/", 0, prefix_end - 1)
299 if prefix_end == -1:
301 prefix_match = self._runfiles.get(path[0:prefix_end])
307 # type: (str) -> Dict[str, str]
322 # type: () -> str
324 return self._path[: -len("/MANIFEST")]
326 return self._path[: -len("_manifest")]
331 # type: () -> Dict[str, str]
346 # type: (str) -> None
354 # type: (str) -> str
357 # tree on Unix platforms, so `Create()` will only create a directory-based
362 # type: () -> Dict[str, str]