Skip to content

Commit

Permalink
[SCons] Make issues importing NumPy easier to diagnose
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jul 31, 2017
1 parent 3d03795 commit 3f69f6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1100,18 +1100,21 @@ if env['python_package'] in ('full', 'default'):
print 'INFO: Using Cython version {0}.'.format(cython_version)

# Test to see if we can import the specified array module
script = '\n'.join(("from distutils.sysconfig import *",
"print get_python_version()",
script = '\n'.join(("from __future__ import print_function",
"from distutils.sysconfig import *",
"print(get_python_version())",
"try:",
" import numpy",
" print numpy.__version__",
"except ImportError:",
" print '0.0.0'",
" print(numpy.__version__)",
"except ImportError as err:",
" import sys",
" print(err, file=sys.stderr)",
" print('0.0.0')",
"import site",
"try:",
" print site.getusersitepackages()",
" print(site.getusersitepackages())",
"except AttributeError:",
" print site.USER_SITE"))
" print(site.USER_SITE)"))

if env['python_array_home']:
script = "sys.path.append({})\n".format(env['python_array_home']) + script
Expand Down Expand Up @@ -1208,7 +1211,9 @@ if env['python3_package'] in ('y', 'default'):
"try:",
" import numpy",
" print(numpy.__version__)",
"except ImportError:",
"except ImportError as err:",
" import sys",
" print(err, file=sys.stderr)",
" print('0.0.0')",
"import site",
"try:",
Expand Down
2 changes: 1 addition & 1 deletion site_scons/buildutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def getCommandOutput(cmd, *args):
if 'PYTHONHOME' in environ:
# Can cause problems when trying to run a different Python interpreter
del environ['PYTHONHOME']
data = subprocess.check_output([cmd] + list(args), stderr=subprocess.STDOUT, env=environ)
data = subprocess.check_output([cmd] + list(args), env=environ)
return data.strip()

# Monkey patch for SCons Cygwin bug
Expand Down

0 comments on commit 3f69f6a

Please sign in to comment.