Skip to content

Commit b5f6f7d

Browse files
committed
Fall back to directory based runfiles using relative paths
This will also work out of the box when the runfiles tree is packaged into a container image.
1 parent f2941df commit b5f6f7d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/runfiles/runfiles.py

+7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def Create(env: Optional[Dict[str, str]] = None) -> Optional["Runfiles"]:
323323
Otherwise, if `env` contains "RUNFILES_DIR" with non-empty value (checked in
324324
this priority order), this method returns a directory-based implementation.
325325
326+
Otherwise, if a valid runfiles folder is found relative to this file, this
327+
method returns a directory-based implementation.
328+
326329
If neither cases apply, this method returns null.
327330
328331
Args:
@@ -339,6 +342,10 @@ def Create(env: Optional[Dict[str, str]] = None) -> Optional["Runfiles"]:
339342
directory = env_map.get("RUNFILES_DIR")
340343
if directory:
341344
return CreateDirectoryBased(directory)
345+
346+
directory = _FindPythonRunfilesRoot()
347+
if os.path.exists(os.path.join(directory, "_repo_mapping")):
348+
return CreateDirectoryBased(directory)
342349

343350
return None
344351

0 commit comments

Comments
 (0)