maintainer-feedback requested: [Bug 243497] [patch] math/py-numpy build fails with OpenBlas

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Jan 21 23:40:33 UTC 2020


Bugzilla Automation <bugzilla at FreeBSD.org> has asked freebsd-python mailing
list <python at FreeBSD.org> for maintainer-feedback:
Bug 243497: [patch] math/py-numpy build fails with OpenBlas
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=243497



--- Description ---
TL;DR

* Problem: Compiling py37-numpy-1.16.5_3,1 with OpenBlas fails in
numpy/distutils/system_info.py with an uncaught distutils.errors.LinkError
exception.
* Solution: also catch distutils.errors.LinkError on line 1742 of
numpy/distutils/system_info.py.

This is the error (only the last part shown for clarity).

    File
"/usr/ports/math/py-numpy/work-py37/numpy-1.16.5/numpy/distutils/system_info.py
",
line 1740, in has_cblas
	extra_postargs=info.get('extra_link_args', []))
    File "/usr/local/lib/python3.7/distutils/ccompiler.py", line 734, in
link_executable
	debug, extra_preargs, extra_postargs, None, target_lang)
    File "/usr/local/lib/python3.7/distutils/unixccompiler.py", line 206, in
link
	raise LinkError(msg)
    distutils.errors.LinkError: Command "cc
/tmp/tmpm3gnb0ev/tmp/tmpm3gnb0ev/source.o -L/usr/local/lib -lblas -o
/tmp/tmpm3gnb0ev/a.out" failed with exit status 1
    *** Error code 1

    Stop.
    make[1]: stopped in /usr/ports/math/py-numpy
    *** Error code 1

    Stop.
    make: stopped in /usr/ports/math/py-numpy

This is the relevant code:

	try:
	    with open(src, 'wt') as f:
		f.write(s)

	    try:
		# check we can compile (find headers)
		obj = c.compile([src], output_dir=tmpdir,
				include_dirs=self.get_include_dirs())

		# check we can link (find library)
		# some systems have separate cblas and blas libs. First
		# check for cblas lib, and if not present check for blas lib.
		try:
		    c.link_executable(obj, os.path.join(tmpdir, "a.out"),
				      libraries=["cblas"],
				      library_dirs=info['library_dirs'],
				     
extra_postargs=info.get('extra_link_args', []))
		    res = "cblas"
		except distutils.ccompiler.LinkError:
		    c.link_executable(obj, os.path.join(tmpdir, "a.out"),
				      libraries=["blas"],
				      library_dirs=info['library_dirs'],
				     
extra_postargs=info.get('extra_link_args', []))
		    res = "blas"
	    except distutils.ccompiler.CompileError:
		res = None
	finally:
	    shutil.rmtree(tmpdir)
	return res

If linking with “cblas” fails, it tries again by linking with “blas”.
However, the last “except” only handles a compilation error but not a linking
error.

When we change:

	    except distutils.ccompiler.CompileError:

to

	    except (distutils.ccompiler.CompileError,
distutils.ccompiler.LinkError):

the problem is fixed.


More information about the freebsd-python mailing list