Skip to content

Commit

Permalink
More Python 3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Dec 8, 2017
1 parent 3b261e4 commit efcc4be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
20 changes: 10 additions & 10 deletions bin/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ Import('env')

# Custom builder to generate file:
def builder_script_file(target, source, env):
infile = file(source[0].abspath, 'r')
outfile = file(target[0].abspath, 'w')
infile = open(source[0].abspath, 'rb')
outfile = open(target[0].abspath, 'wb')
for line in infile:
line = line.rstrip('\r\n')
if line.endswith("@TOPDIR@"):
line = "TOPDIR=" + source[1].get_contents()
elif line.endswith("@MODPY@"):
line = "MODPY=" + source[2].get_contents()
elif line.endswith("@PATHSEP@"):
line = "PATHSEP=\"" + source[3].get_contents() + "\""
print >> outfile, line
line = line.rstrip(b'\r\n')
if line.endswith(b"@TOPDIR@"):
line = b"TOPDIR=" + source[1].get_contents()
elif line.endswith(b"@MODPY@"):
line = b"MODPY=" + source[2].get_contents()
elif line.endswith(b"@PATHSEP@"):
line = b"PATHSEP=\"" + source[3].get_contents() + b"\""
outfile.write(line + b"\n")
outfile.close()
infile.close()
# 1877 = octal 0755
Expand Down
9 changes: 5 additions & 4 deletions pyext/SConscript
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
Import('env', 'get_pyext_environment')

Expand All @@ -9,18 +10,18 @@ e.MergeFlags(e['GLIB'])
# Check for NumPy support:
if not e.GetOption('clean') and not e.GetOption('help') \
and not e['wine'] and not e['wine64']:
print "Checking for numpy...",
print("Checking for numpy...", end='')
try:
import numpy
path = os.path.join(numpy.__path__[0], 'core', 'include')
if os.path.exists(path):
e.Append(CPPDEFINES=[('MDT_WITH_NUMPY', 1)])
print "found in " + path
print("found in " + path)
e.Append(CPPPATH=[path])
else:
print "module found, but no headers"
print("module found, but no headers")
except ImportError:
print "not found"
print("not found")

e.Append(LIBPATH=['../src'])
e.Append(LIBS=['mdt'])
Expand Down
2 changes: 1 addition & 1 deletion test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def builder_unit_test(target, source, env):
app = "%s %s %s %s-v > %s" % (source[1].abspath, e['PYTHON'],
source[0], opts, e['DEVNULL'])
if c.Execute(app) == 0:
file(str(target[0]), 'w').write('PASSED\n')
open(str(target[0]), 'w').write('PASSED\n')
else:
sys.stdout.write("unit tests FAILED\n")
return 1
Expand Down

0 comments on commit efcc4be

Please sign in to comment.