pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: py-scipy build failure



Patrick Welche <prlw1%welche.eu@localhost> writes:

> As per
>
>   http://shadow.netbsd.org/pub/pkgsrc/packages/reports/HEAD/NetBSD-10.0-x86_64/20250110.0034//py311-scipy-1.15.0/build.log
>
> py-scipy is failing to build. FWIW I just managed a successful build with
>
> # cat patch-scipy_special_stirling2.h
> $NetBSD$
>
> --- scipy/special/stirling2.h.orig      2025-01-02 22:53:29.000000000 +0000
> +++ scipy/special/stirling2.h
> @@ -4,13 +4,17 @@
>  #if defined(__cplusplus)
>  #include <cmath>
>  using std::isinf;
> -#endif
> -
> +#include <complex>
> +#else
>  #include <complex.h>
>  #include <math.h>
> +#endif
> +
> +/*
>  #include <stdio.h>
>  #include <stdint.h>
>  #include <stdlib.h>
> +*/
>  
>  #include "xsf/binom.h"
>  #include "xsf/lambertw.h"

I am also having failure to build, NetBSD 10_STABLE amd64, py312.

I am using your patch, except not omitting st{io,int,lib}.h.   Since
diff and ifdefs are hard to read, the patched file looks like:

  #if defined(__cplusplus)
  #include <cmath>
  #include <complex>
  using std::isinf;
  #else   /* __cplusplus */
  #include <math.h>
  #include <complex.h>
  #endif  /* __cplusplus */

  #include <stdio.h>
  #include <stdint.h>
  #include <stdlib.h>

Builds and only 7 tests fail.  My gut says that is great, not a
regression:

  FAILED optimize/tests/test_zeros.py::TestNewton::test_halley_collections - AssertionError: 
  FAILED special/tests/test_basic.py::TestCephes::test_expm1_complex - AssertionError: 
  FAILED special/tests/test_basic.py::TestCephes::test_log1p_complex - AssertionError: 
  FAILED special/tests/test_basic.py::test_error_raising - Failed: DID NOT RAISE <class 'scipy.special._sf_error.SpecialFunctionError'>
  FAILED special/tests/test_sf_error.py::test_errstate_pyx_basic - Failed: DID NOT RAISE <class 'scipy.special._sf_error.SpecialFunctionError'>
  FAILED special/tests/test_sf_error.py::test_errstate_cpp_scipy_special - Failed: DID NOT RAISE <class 'scipy.special._sf_error.SpecialFunctionError'>
  FAILED special/tests/test_sf_error.py::test_errstate_cpp_alt_ufunc_machinery - Failed: DID NOT RAISE <class 'scipy.special._sf_error.SpecialFunctionError'>
  ====== 7 failed, 61227 passed, 2788 skipped, 271 xfailed, 14 xpassed, 106 warnings in 1061.11s (0:17:41) =====

Is the core issue that complex is a keyword in C++, and a header that
typedefs it is wrong?  Do you think this is a scipy bug, a NetBSD bug,
both, neither?

Do you think we should commit this?  (your fix, plus sorting
USE_LANGUAGES correctly, not important):


Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/math/py-scipy/Makefile,v
retrieving revision 1.91
diff -u -p -r1.91 Makefile
--- Makefile	8 Jan 2025 12:46:26 -0000	1.91
+++ Makefile	14 Jan 2025 01:04:42 -0000
@@ -22,9 +22,9 @@ TEST_DEPENDS+=	${PYPKGPREFIX}-test-cov-[
 TEST_DEPENDS+=	${PYPKGPREFIX}-test-timeout-[0-9]*:../../devel/py-test-timeout
 TEST_DEPENDS+=	${PYPKGPREFIX}-test-xdist-[0-9]*:../../devel/py-test-xdist
 
+USE_LANGUAGES=		c c++ fortran
 USE_CC_FEATURES=	c17
 USE_CXX_FEATURES=	c++17
-USE_LANGUAGES=		c c++ fortran
 USE_TOOLS+=		pkg-config
 MAKE_ENV+=		ATLAS=None
 # Upstream explicitly checks for 9; see meson.build.
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/math/py-scipy/distinfo,v
retrieving revision 1.56
diff -u -p -r1.56 distinfo
--- distinfo	7 Jan 2025 15:38:35 -0000	1.56
+++ distinfo	14 Jan 2025 01:04:42 -0000
@@ -9,6 +9,7 @@ SHA1 (patch-scipy_spatial_ckdtree_src_ck
 SHA1 (patch-scipy_special_Faddeeva.hh) = 9f6c0bb808fc9be0a1c1b7e65395d29f13821233
 SHA1 (patch-scipy_special_boost__special__functions.h) = 9a345a5e81c090d16c6394e641624c504efbf4ea
 SHA1 (patch-scipy_special_meson.build) = db22da79b31a0fb8dbdac96f398463f4d24adfe0
+SHA1 (patch-scipy_special_stirling2.h) = 08bfa2a96e60670ebd58e7fbfb73c674987800ab
 SHA1 (patch-scipy_special_wright.hh) = 56d65f9ed4bec96f0b927bbe42edd30fc6546454
 SHA1 (patch-scipy_special_xsf_amos_amos.h) = 4d757b98ab6c98bac2d6e3b6f01f4ad5d02c2afb
 SHA1 (patch-scipy_special_xsf_specfun_specfun.h) = 67fa2ad7980bb836a0d490a8bc7891b535c9bf35
Index: patches/patch-scipy_special_stirling2.h
===================================================================
RCS file: patches/patch-scipy_special_stirling2.h
diff -N patches/patch-scipy_special_stirling2.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-scipy_special_stirling2.h	14 Jan 2025 01:04:42 -0000
@@ -0,0 +1,36 @@
+$NetBSD$
+
+On NetBSD, scipy fails to build with many errors like:
+
+  FAILED: scipy/special/_ufuncs_cxx.so.p/meson-generated__ufuncs_cxx.cpp.o 
+c++ -Iscipy/special/_ufuncs_cxx.so.p -Iscipy/special -I../scipy/special -I../scipy/_lib/boost_math/include -Iscipy/_lib -I../scipy/_lib -I../scipy/_build_utils/src -I../../../../../../../usr/pkg/lib/python3.11/site-packages/numpy/_core/include -I/usr/pkg/include/python3.11 -I/usr/pkg/include -I/usr/include -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O3 -O2 -D__STDC_FORMAT_MACROS -fPIC -DSP_SPECFUN_ERROR -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -DCYTHON_CCOMPLEX=0 -DBOOST_MATH_STANDALONE=1 '-DCYTHON_EXTERN_C=extern "C"' -MD -MQ scipy/special/_ufuncs_cxx.so.p/meson-generated__ufuncs_cxx.cpp.o -MF scipy/special/_ufuncs_cxx.so.p/meson-generated__ufuncs_cxx.cpp.o.d -o scipy/special/_ufuncs_cxx.so.p/meson-generated__ufuncs_cxx.cpp.o -c scipy/special/_ufuncs_cxx.so.p/_ufuncs_cxx.cpp
+In file included from ../scipy/special/stirling2.h:9,
+                 from scipy/special/_ufuncs_cxx_defs.h:112,
+                 from scipy/special/_ufuncs_cxx.so.p/_ufuncs_cxx.cpp:1246:
+../scipy/special/xsf/evalpoly.h:26:29: error: expected unqualified-id before '_Complex'
+   26 | XSF_HOST_DEVICE inline std::complex<double> cevalpoly(const double *coeffs, int degree, std::complex<double> z) {
+      |                             ^~~~~~~
+
+
+On the theory that typedef of complex in C++ is not ok, switch to using C++ headers in C++ mode.
+Not yet sent upstream.
+
+--- scipy/special/stirling2.h.orig	2025-01-13 23:39:01.039575715 +0000
++++ scipy/special/stirling2.h
+@@ -3,11 +3,13 @@
+ 
+ #if defined(__cplusplus)
+ #include <cmath>
++#include <complex>
+ using std::isinf;
+-#endif
+-
+-#include <complex.h>
++#else	/* __cplusplus */
+ #include <math.h>
++#include <complex.h>
++#endif	/* __cplusplus */
++
+ #include <stdio.h>
+ #include <stdint.h>
+ #include <stdlib.h>


Home | Main Index | Thread Index | Old Index