From 2711bdf8dd80cfc3c5a8c2999819c88fb88095f3 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sat, 14 Apr 2012 18:32:49 +0100 Subject: [PATCH] Fix writing git commit ID to a file on build with Python 3. --- setupbase.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/setupbase.py b/setupbase.py index fe6e35701..0bf0bb186 100644 --- a/setupbase.py +++ b/setupbase.py @@ -20,7 +20,6 @@ from __future__ import print_function #------------------------------------------------------------------------------- # Imports #------------------------------------------------------------------------------- -import io import os import sys @@ -55,11 +54,6 @@ except NameError: locs = locs or globs exec(compile(open(fname).read(), fname, "exec"), globs, locs) -try: - unicode -except NameError: - unicode = str - # A little utility we'll need below, since glob() does NOT allow you to do # exclusion on multiple endings! def file_doesnt_endwith(test,endings): @@ -396,9 +390,9 @@ def record_commit_info(pkg_dir, build_cmd=build_py): repo_commit = repo_commit.strip() # We write the installation commit even if it's empty out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py') - with io.open(out_pth, 'w') as out_file: - out_file.writelines(map(unicode, [ + with open(out_pth, 'w') as out_file: + out_file.writelines([ '# GENERATED BY setup.py\n', - 'commit = "%s"\n' % repo_commit, - ])) + 'commit = "%s"\n' % repo_commit.decode('ascii'), + ]) return MyBuildPy