From ddefaf7a2cf6cc240b6d13fb0c83c46afbbd13af Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 3 Jul 2011 21:58:18 -0400 Subject: [PATCH] Aksetup, setup fixes for Py3, closing of opened files. --- aksetup_helper.py | 10 ++++++++-- setup.py | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/aksetup_helper.py b/aksetup_helper.py index 88bdb916..10db6a2f 100644 --- a/aksetup_helper.py +++ b/aksetup_helper.py @@ -282,7 +282,13 @@ class ConfigSchema: def read_config_from_pyfile(self, filename): result = {} filevars = {} - exec(compile(open(filename, "r").read(), filename, "exec"), filevars) + infile = open(filename, "r") + try: + contents = infile.read() + finally: + infile.close() + + exec(compile(contents, filename, "exec"), filevars) for key, value in filevars.items(): if key in self.optdict: @@ -574,7 +580,7 @@ def set_up_shipped_boost_if_requested(project_name, conf): from os import symlink except ImportError: from shutil import copytree - print "Copying files, hang on... (do not interrupt)" + print("Copying files, hang on... (do not interrupt)") copytree(main_boost_inc, bpl_project_boost_inc) else: symlink("boost", bpl_project_boost_inc) diff --git a/setup.py b/setup.py index a514ceb6..655bffd7 100644 --- a/setup.py +++ b/setup.py @@ -80,7 +80,13 @@ def main(): EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1 ver_dic = {} - exec(compile(open("pyopencl/version.py").read(), "pyopencl/version.py", 'exec'), ver_dic) + version_file = open("pyopencl/version.py") + try: + version_file_contents = version_file.read() + finally: + version_file.close() + + exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic) try: from distutils.command.build_py import build_py_2to3 as build_py -- GitLab