diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BUILD index dbcd04e8b0687b..26da7689d97889 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BUILD @@ -22,6 +22,7 @@ java_library( deps = [ "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", + "//src/main/java/com/google/devtools/build/lib/actions:commandline_item", "//src/main/java/com/google/devtools/build/lib/analysis:actions/custom_command_line", "//src/main/java/com/google/devtools/build/lib/analysis:actions/launcher_file_write_action", "//src/main/java/com/google/devtools/build/lib/analysis:actions/substitution", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java index a76ba940ad72d9..94ef431c5e10f3 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java @@ -20,6 +20,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.CommandLineItem; import com.google.devtools.build.lib.actions.ParamFileInfo; import com.google.devtools.build.lib.actions.ParameterFile; import com.google.devtools.build.lib.analysis.AnalysisUtils; @@ -367,12 +368,24 @@ private static void createPythonZipAction( // Read each runfile from execute path, add them into zip file at the right runfiles path. // Filter the executable file, cause we are building it. + argv.addAll( + CustomCommandLine.VectorArg.of(runfilesSupport.getRunfilesArtifacts()) + .mapped( + (CommandLineItem.CapturingMapFn) + (artifact, args) -> { + if (!artifact.equals(executable) && !artifact.equals(zipFile)) { + args.accept( + getZipRunfilesPath( + artifact.getRunfilesPath(), + workspaceName, + legacyExternalRunfiles) + + "=" + + artifact.getExecPathString()); + } + })); + for (Artifact artifact : runfilesSupport.getRunfilesArtifacts().toList()) { if (!artifact.equals(executable) && !artifact.equals(zipFile)) { - argv.addDynamicString( - getZipRunfilesPath(artifact.getRunfilesPath(), workspaceName, legacyExternalRunfiles) - + "=" - + artifact.getExecPathString()); inputsBuilder.add(artifact); } }