diff options
author | 2017-01-13 15:16:03 +0000 | |
---|---|---|
committer | 2017-01-13 16:12:58 +0000 | |
commit | 4268c6e05d27e59a2f9861eaf3b67885cd741605 (patch) | |
tree | 335980f032e4f0c3774abd5330aab6fb7dea14bb /src/main | |
parent | 9f60395a04410abe3068c3e0fafbc917193d3f8a (diff) |
Tell Python binaries the location of their runfiles tree using the RUNFILES_DIR environment variable.
Note that this is slightly different from the Java launcher (where the same is JAVA_RUNFILES)
Fixes #2339.
--
PiperOrigin-RevId: 144439111
MOS_MIGRATED_REVID=144439111
Diffstat (limited to 'src/main')
3 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java index dd2d5de509..a7723f7b8e 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java @@ -218,15 +218,17 @@ public class BaseSpawn implements Spawn { PathFragment runfilesRoot = getRunfilesRoot(); if (runfilesRoot == null || (environment.containsKey("JAVA_RUNFILES") - && environment.containsKey("PYTHON_RUNFILES"))) { + && environment.containsKey("PYTHON_RUNFILES") + && environment.containsKey("RUNFILES_DIR"))) { return environment; } else { ImmutableMap.Builder<String, String> env = ImmutableMap.builder(); env.putAll(environment); - // TODO(bazel-team): Unify these into a single env variable. + // TODO(bazel-team): Remove JAVA_RUNFILES and PYTHON_RUNFILES. String runfilesRootString = runfilesRoot.getPathString(); env.put("JAVA_RUNFILES", runfilesRootString); env.put("PYTHON_RUNFILES", runfilesRootString); + env.put("RUNFILES_DIR", runfilesRootString); return env.build(); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/stub_template.txt index 04316fea4d..55f0e7e488 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/stub_template.txt @@ -105,6 +105,7 @@ def Main(): python_path += separator + old_python_path new_env['PYTHONPATH'] = python_path + new_env['RUNFILES_DIR'] = module_space # Now look for my main python source file. # The magic string percent-main-percent is replaced with the filename of the diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java index 9b2e1d3ab8..b444544ca6 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java @@ -248,6 +248,7 @@ public class StandaloneTestStrategy extends TestStrategy { String testSrcDir = runfilesDir.relativeTo(execRoot).getPathString(); env.put("JAVA_RUNFILES", testSrcDir); env.put("PYTHON_RUNFILES", testSrcDir); + env.put("RUNFILES_DIR", testSrcDir); env.put("TEST_SRCDIR", testSrcDir); env.put("TEST_TMPDIR", tmpDirString); env.put("TEST_WORKSPACE", action.getRunfilesPrefix()); |