Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): Set envvar for runfiles manifest, not runfiles dir, when using a manifest #17722

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tools/python/python_bootstrap_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ def GetRepositoriesImports(module_space, import_all):
return [os.path.join(module_space, '%workspace_name%')]

def RunfilesEnvvar(module_space):
"""Finds the runfiles manifest or the runfiles directory."""
"""Finds the runfiles manifest or the runfiles directory.

Returns:
A tuple of (var_name, var_value) where var_name is either 'RUNFILES_DIR' or
'RUNFILES_MANIFEST_FILE' and var_value is the path to that directory or
file, or (None, None) if runfiles couldn't be found.
"""
# If this binary is the data-dependency of another one, the other sets
# RUNFILES_MANIFEST_FILE or RUNFILES_DIR for our sake.
runfiles = os.environ.get('RUNFILES_MANIFEST_FILE', None)
Expand All @@ -236,9 +242,12 @@ def RunfilesEnvvar(module_space):
return ('RUNFILES_MANIFEST_FILE', runfiles)

# Look for the runfiles "input" manifest, argv[0] + ".runfiles/MANIFEST"
rickeylev marked this conversation as resolved.
Show resolved Hide resolved
# Normally .runfiles_manifest and MANIFEST are both present, but the
# former will be missing for zip-based builds or if someone copies the
# runfiles tree elsewhere.
runfiles = os.path.join(module_space, 'MANIFEST')
if os.path.exists(runfiles):
return ('RUNFILES_DIR', runfiles)
return ('RUNFILES_MANIFEST_FILE', runfiles)
rickeylev marked this conversation as resolved.
Show resolved Hide resolved

# If running in a sandbox and no environment variables are set, then
# Look for the runfiles next to the binary.
Expand Down