From owner-freebsd-python@freebsd.org  Tue Jan 21 23:40:33 2020
Return-Path: <owner-freebsd-python@freebsd.org>
Delivered-To: freebsd-python@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC884226538
 for <freebsd-python@mailman.nyi.freebsd.org>;
 Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::50:13])
 by mx1.freebsd.org (Postfix) with ESMTP id 482Q5F57fRz4Cqw
 for <freebsd-python@freebsd.org>; Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: by mailman.nyi.freebsd.org (Postfix)
 id AE6D7226537; Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
Delivered-To: python@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE2ED226536
 for <python@mailman.nyi.freebsd.org>; Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 482Q5F4F2Gz4Cqv
 for <python@FreeBSD.org>; Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org (kenobi.freebsd.org
 [IPv6:2610:1c1:1:606c::50:1d])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 882F61C72A
 for <python@FreeBSD.org>; Tue, 21 Jan 2020 23:40:33 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org ([127.0.1.5])
 by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 00LNeXts002987
 for <python@FreeBSD.org>; Tue, 21 Jan 2020 23:40:33 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
Received: (from www@localhost)
 by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 00LNeXYj002986
 for python@FreeBSD.org; Tue, 21 Jan 2020 23:40:33 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
X-Authentication-Warning: kenobi.freebsd.org: www set sender to
 bugzilla-noreply@freebsd.org using -f
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="UTF-8"
From: bugzilla-noreply@freebsd.org
To: python@FreeBSD.org
Subject: maintainer-feedback requested: [Bug 243497] [patch] math/py-numpy
 build fails with OpenBlas
Date: Tue, 21 Jan 2020 23:40:33 +0000
X-Bugzilla-Type: request
X-Bugzilla-Product: Ports & Packages
X-Bugzilla-Component: Individual Port(s)
X-Bugzilla-Version: Latest
X-Bugzilla-Keywords: 
X-Bugzilla-Severity: Affects Only Me
X-Bugzilla-Who: 
X-Bugzilla-Status: New
X-Bugzilla-Resolution: 
X-Bugzilla-Priority: ---
X-Bugzilla-Assigned-To: python@FreeBSD.org
X-Bugzilla-Flags: maintainer-feedback?
Message-ID: <bug-243497-21822-uLQhfzrTFD@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-243497-21822@https.bugs.freebsd.org/bugzilla/>
References: <bug-243497-21822@https.bugs.freebsd.org/bugzilla/>
X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-BeenThere: freebsd-python@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FreeBSD-specific Python issues <freebsd-python.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-python>, 
 <mailto:freebsd-python-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-python/>
List-Post: <mailto:freebsd-python@freebsd.org>
List-Help: <mailto:freebsd-python-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-python>,
 <mailto:freebsd-python-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 21 Jan 2020 23:40:33 -0000

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



--- 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_inf=
o.py
",
line 1740, in has_cblas
	extra_postargs=3Dinfo.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 =3D c.compile([src], output_dir=3Dtmpdir,
				include_dirs=3Dself.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=3D["cblas"],
				      library_dirs=3Dinfo['library_dirs'],
=09=09=09=09=20=20=20=20=20
extra_postargs=3Dinfo.get('extra_link_args', []))
		    res =3D "cblas"
		except distutils.ccompiler.LinkError:
		    c.link_executable(obj, os.path.join(tmpdir, "a.out"),
				      libraries=3D["blas"],
				      library_dirs=3Dinfo['library_dirs'],
=09=09=09=09=20=20=20=20=20
extra_postargs=3Dinfo.get('extra_link_args', []))
		    res =3D "blas"
	    except distutils.ccompiler.CompileError:
		res =3D None
	finally:
	    shutil.rmtree(tmpdir)
	return res

If linking with =E2=80=9Ccblas=E2=80=9D fails, it tries again by linking wi=
th =E2=80=9Cblas=E2=80=9D.
However, the last =E2=80=9Cexcept=E2=80=9D 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.