diff options
author | 2016-08-10 15:51:12 +0000 | |
---|---|---|
committer | 2016-08-11 09:13:25 +0000 | |
commit | 239f0cf923a0c914d615d8a33091b5635099fb55 (patch) | |
tree | 6f27c583485cd541e3341490b06f86983c73f088 | |
parent | 4994cb35f634b18a21b85fe16fbaaed4abd0a36e (diff) |
Get rid of python exectuable zip file header
We don't have to add the stub_template.txt as the python
zip file header except a simple '#!/usr/bin/env python' shebang, because it's
equivalent to 'python <file>'. Apparently, python checks the file
type firstly, if it's a zip file, it will find and run __main__.py
instead of running the header script.
--
Change-Id: Icbd3bacacc3857dc3b857d3a7cb770fd94362b9d
Reviewed-on: https://bazel-review.googlesource.com/#/c/5350
MOS_MIGRATED_REVID=129870674
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java | 7 |
1 files changed, 2 insertions, 5 deletions
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 3d95040236..9083a510ff 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 @@ -158,7 +158,7 @@ public class BazelPythonSemantics implements PythonSemantics { } importPaths.add(path); } - // The executable zip file wil unzip itself into a tmp directory and then run from there + // The executable zip file will unzip itself into a tmp directory and then run from there ruleContext.registerAction( new TemplateExpansionAction( ruleContext.getActionOwner(), @@ -175,12 +175,9 @@ public class BazelPythonSemantics implements PythonSemantics { ruleContext.registerAction( new SpawnAction.Builder() .addInput(zipFile) - .addInput(templateMain) .addOutput(executable) .setShellCommand( - "cat " - + templateMain.getExecPathString() - + " " + "echo '#!/usr/bin/env python' | cat - " + zipFile.getExecPathString() + " > " + executable.getExecPathString()) |