aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/create_embedded_tools.py
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2017-08-09 12:03:03 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-09 12:39:03 +0200
commit5a661c793f54b092c5bfc2f4f0049c9f2e317843 (patch)
tree7b10b7692e3aa3dad4e45762227b51c03208ddaf /src/create_embedded_tools.py
parente8a3fea51f8c37392aad33784ae5b92947502e68 (diff)
Make create_embedded_tools.py python 2.6 friendly
Centos 6.7 provides only python 2.6. And since we test bazel with this version, let's replace the only python 2.7 use with the python 2.6 friendly code. RELNOTES: None. PiperOrigin-RevId: 164704194
Diffstat (limited to 'src/create_embedded_tools.py')
-rw-r--r--src/create_embedded_tools.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/create_embedded_tools.py b/src/create_embedded_tools.py
index e9383140e1..a4ba83a06e 100644
--- a/src/create_embedded_tools.py
+++ b/src/create_embedded_tools.py
@@ -14,6 +14,7 @@
# limitations under the License.
"""Creates the embedded_tools.zip that is part of the Bazel binary."""
+import contextlib
import fnmatch
import os
import os.path
@@ -132,7 +133,8 @@ def copy_jdk_into_archive(output_zip, archive_file, input_file):
# Ignore directories, hard links, special files, ...
pass
elif archive_file.endswith('.zip'):
- with zipfile.ZipFile(input_file, 'r') as jdk_zip:
+ # Adding contextlib.closing to be python 2.6 (for centos 6.7) compatible
+ with contextlib.closing(zipfile.ZipFile(input_file, 'r')) as jdk_zip:
for jdk_zipinfo in jdk_zip.infolist():
# Rename the first folder to 'jdk', because Bazel looks for a
# bundled JDK in the embedded tools using that folder name.
@@ -151,7 +153,9 @@ def main():
input_files = get_input_files(sys.argv[2])
# Copy all the input_files into output_zip.
- with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as output_zip:
+ # Adding contextlib.closing to be python 2.6 (for centos 6.7) compatible
+ with contextlib.closing(
+ zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED)) as output_zip:
zipinfo = zipfile.ZipInfo('WORKSPACE', (1980, 1, 1, 0, 0, 0))
zipinfo.external_attr = 0o644 << 16
output_zip.writestr(zipinfo, 'workspace(name = "bazel_tools")\n')