Merge pull request #1594 from takluyver/setupbase-py3

Fix writing git commit ID to a file on build with Python 3

use builtin open / str literals instead of io.open & unicode.
This commit is contained in:
Min RK 2012-04-14 11:39:00 -07:00
commit ee9cbf39cb

View File

@ -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