Date: Wednesday, January 16, 2019 @ 07:39:17 Author: arojas Revision: 423473
Update to 8.6 Added: sagemath/trunk/sagemath-numpy-1.16.patch ---------------------------+ sagemath-numpy-1.16.patch | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) Added: sagemath-numpy-1.16.patch =================================================================== --- sagemath-numpy-1.16.patch (rev 0) +++ sagemath-numpy-1.16.patch 2019-01-16 07:39:17 UTC (rev 423473) @@ -0,0 +1,85 @@ +diff --git a/src/sage/misc/inline_fortran.py b/src/sage/misc/inline_fortran.py +index e44724b..2bb4852 100644 +--- a/src/sage/misc/inline_fortran.py ++++ b/src/sage/misc/inline_fortran.py +@@ -5,6 +5,7 @@ from __future__ import absolute_import + + import os + import shutil ++import subprocess + import sys + + import six +@@ -154,8 +155,6 @@ class InlineFortran: + from sage.repl.user_globals import get_globals + globals = get_globals() + +- from numpy import f2py +- + # Create everything in a temporary directory + mytmpdir = tmp_dir() + +@@ -171,36 +170,44 @@ class InlineFortran: + else: + fortran_file = name + '.f' + +- s_lib_path = "" +- s_lib = "" +- for s in self.library_paths: +- s_lib_path = s_lib_path + "-L%s " ++ s_lib_path = ['-L' + p for p in self.library_paths] ++ s_lib = ['-l' + l for l in self.libraries] + +- for s in self.libraries: +- s_lib = s_lib + "-l%s "%s ++ with open(fortran_file, 'w') as fobj: ++ fobj.write(x) + +- log = name + ".log" +- extra_args = ('--quiet --f77exec=sage-inline-fortran ' +- '--f90exec=sage-inline-fortran {lib_path} {lib} ' +- '> {log} 2>&1'.format(lib_path=s_lib_path, +- lib=s_lib, log=log)) ++ # This is basically the same as what f2py.compile() does, but we ++ # do it manually here in order to customize running the subprocess ++ # a bit more (in particular to capture stderr) ++ cmd = [sys.executable, '-c', 'import numpy.f2py; numpy.f2py.main()'] + +- f2py.compile(x, name, extra_args=extra_args, +- source_fn=fortran_file) ++ # What follows are the arguments to f2py itself (appended later ++ # just for logical separation) ++ cmd += ['-c', '-m', name, fortran_file, '--quiet', ++ '--f77exec=sage-inline-fortran', ++ '--f90exec=sage-inline-fortran'] + s_lib_path + s_lib + +- with open(log) as fobj: +- log_string = fobj.read() ++ try: ++ out = subprocess.check_output(cmd, stderr=subprocess.STDOUT) ++ except subprocess.CalledProcessError as exc: ++ raise RuntimeError( ++ "failed to compile Fortran code:\n{}".format(exc.output)) + + # Note that f2py() doesn't raise an exception if it fails. + # In that case, the import below will fail. + try: + mod = _import_module_from_path(name, [mytmpdir]) +- except ImportError: +- raise RuntimeError("failed to compile Fortran code:\n" + +- log_string) ++ except ImportError as exc: ++ # Failed to import the module; include any output from building ++ # the module (even though it was ostensibly successful) in case ++ # it might help ++ msg = "failed to load compiled Fortran code: {}".format(exc) ++ if out: ++ msg += '\n' + out ++ raise RuntimeError(msg) + + if self.verbose: +- print(log_string) ++ print(out) + finally: + os.chdir(old_cwd) +