From 5a661c793f54b092c5bfc2f4f0049c9f2e317843 Mon Sep 17 00:00:00 2001 From: hlopko Date: Wed, 9 Aug 2017 12:03:03 +0200 Subject: 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 --- src/create_embedded_tools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/create_embedded_tools.py') 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') -- cgit v1.2.3