GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Numpy 1.26.0 doesn't work on freebsd · Issue #24873 · numpy/numpy

Numpy 1.26.0 doesn't work on freebsd #24873

New issue
Copy link
New issue
Copy link
Closed
#24876
Closed
Numpy 1.26.0 doesn't work on freebsd#24873
#24876
Copy link
Labels
32 - InstallationProblems installing or compiling NumPy
Milestone
1.26.1 release

Description

@LukaszMoskala
LukaszMoskala
opened on Oct 6, 2023
Issue body actions

Steps to reproduce:

python3.11 -m venv npv
. npv/bin/activate
pip install numpy==1.26.0
python
>>> import numpy

Error message:

Python 3.11.5 (main, Sep  7 2023, 03:42:48) [Clang 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386 on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/__init__.py", line 130, in <module>
    from numpy.__config__ import show as show_config
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/__config__.py", line 4, in <module>
    from numpy.core._multiarray_umath import (
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/core/__init__.py", line 100, in <module>
    from . import _add_newdocs
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/core/_add_newdocs.py", line 4973, in <module>
    add_newdoc('numpy.core._multiarray_tests', 'format_float_OSprintf_g',
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/core/function_base.py", line 543, in add_newdoc
    new = getattr(__import__(place, globals(), {}, [obj]), obj)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: /usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/core/_multiarray_tests.cpython-311.so: Undefined symbol "ccosl"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/home/lmoskala/npv/lib/python3.11/site-packages/numpy/__init__.py", line 135, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
>>>

Additional information:

FreeBSD 13.2 with python3.11.5 (python 3.11.2 has the same issue).

If I do pip install numpy==1.24.1, then import numpy succeeds. Numpy 1.25.2 also works. So I'd guess that somewhere between 1.25.2 and 1.26.0 #22850 stopped working? of a new function appeared?

I'll try to provide any informations needed.

Reacted by tehfink

Activity

  1. LukaszMoskala
    added
    32 - InstallationProblems installing or compiling NumPy
    on Oct 6, 2023
  2. charris
    added this to the 1.26.1 release milestone on Oct 6, 2023
  3. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    Thanks for the report @LukaszMoskala. Looking at gh-22850, I noticed it was just linked to from ggml-org/llama.cpp#3511 with a very similar error. So it looks like the complex long double feature checks are somehow not working as they should. They're defined here:

    numpy/numpy/core/meson.build

    Lines 168 to 187 in 195d85b

    c99_complex_funcs = [
    'cabs', 'cacos', 'cacosh', 'carg', 'casin', 'casinh', 'catan',
    'catanh', 'cexp', 'clog', 'cpow', 'csqrt',
    # The long double variants (like csinl) should be mandatory on C11,
    # but are missing in FreeBSD. Issue gh-22850
    'csin', 'csinh', 'ccos', 'ccosh', 'ctan', 'ctanh',
    ]
    foreach func: c99_complex_funcs
    func_single = func + 'f'
    func_longdouble = func + 'l'
    if cc.has_function(func)
    cdata.set10('HAVE_' + func.to_upper(), true)
    endif
    if cc.has_function(func_single)
    cdata.set10('HAVE_' + func_single.to_upper(), true)
    endif
    if cc.has_function(func_longdouble)
    cdata.set10('HAVE_' + func_longdouble.to_upper(), true)
    endif
    endforeach

    @LukaszMoskala the build log should contain the result of every feature check, like this:

    Checking for function "ccos" : YES (cached)
    Checking for function "ccosf" : YES 
    Checking for function "ccosl" : YES 
    

    Could you re-run the build with the -v flag for pip, and check what the result of those checks is?

  4. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    I think I see the problem: the use of cdata.set10 will result in: EDIT: probably not true, the if cc.has_function should prevent this)

    #define HAVE_CCOSL 0

    however it shouldn't be defined at all - because the C code will check with #ifndef HAVE_CCOSL.

    I think it's time to add a FreeBSD CI job when fixing this, because it's too easy to cause a regression on a platform that isn't C99 compliant.

  5. LukaszMoskala commented on Oct 7, 2023

    @LukaszMoskala
    LukaszMoskala
    on Oct 7, 2023
    Author
    More actions

    Sure, here are all my "checking for function..." lines.

      Checking for function "sin" : YES
      Checking for function "cos" : YES
      Checking for function "tan" : YES
      Checking for function "sinh" : YES
      Checking for function "cosh" : YES
      Checking for function "tanh" : YES
      Checking for function "fabs" : YES
      Checking for function "floor" : YES
      Checking for function "ceil" : YES
      Checking for function "sqrt" : YES
      Checking for function "log10" : YES
      Checking for function "log" : YES
      Checking for function "exp" : YES
      Checking for function "asin" : YES
      Checking for function "acos" : YES
      Checking for function "atan" : YES
      Checking for function "fmod" : YES
      Checking for function "modf" : YES
      Checking for function "frexp" : YES
      Checking for function "ldexp" : YES
      Checking for function "expm1" : YES
      Checking for function "log1p" : YES
      Checking for function "acosh" : YES
      Checking for function "asinh" : YES
      Checking for function "atanh" : YES
      Checking for function "rint" : YES
      Checking for function "trunc" : YES
      Checking for function "exp2" : YES
      Checking for function "copysign" : YES
      Checking for function "nextafter" : YES
      Checking for function "strtoll" : YES
      Checking for function "strtoull" : YES
      Checking for function "cbrt" : YES
      Checking for function "log2" : YES
      Checking for function "pow" : YES
      Checking for function "hypot" : YES
      Checking for function "atan2" : YES
      Checking for function "csin" : YES
      Checking for function "csinh" : YES
      Checking for function "ccos" : YES
      Checking for function "ccosh" : YES
      Checking for function "ctan" : YES
      Checking for function "ctanh" : YES
      Checking for function "creal" : YES
      Checking for function "cimag" : YES
      Checking for function "conj" : YES
      Checking for function "cabs" : YES
      Checking for function "cabsf" : YES
      Checking for function "cabsl" : YES
      Checking for function "cacos" : YES
      Checking for function "cacosf" : YES
      Checking for function "cacosl" : YES
      Checking for function "cacosh" : YES
      Checking for function "cacoshf" : YES
      Checking for function "cacoshl" : YES
      Checking for function "carg" : YES
      Checking for function "cargf" : YES
      Checking for function "cargl" : YES
      Checking for function "casin" : YES
      Checking for function "casinf" : YES
      Checking for function "casinl" : YES
      Checking for function "casinh" : YES
      Checking for function "casinhf" : YES
      Checking for function "casinhl" : YES
      Checking for function "catan" : YES
      Checking for function "catanf" : YES
      Checking for function "catanl" : YES
      Checking for function "catanh" : YES
      Checking for function "catanhf" : YES
      Checking for function "catanhl" : YES
      Checking for function "cexp" : YES
      Checking for function "cexpf" : YES
      Checking for function "cexpl" : YES
      Checking for function "clog" : YES
      Checking for function "clogf" : YES
      Checking for function "clogl" : YES
      Checking for function "cpow" : YES
      Checking for function "cpowf" : YES
      Checking for function "cpowl" : YES
      Checking for function "csqrt" : YES
      Checking for function "csqrtf" : YES
      Checking for function "csqrtl" : YES
      Checking for function "csin" : YES (cached)
      Checking for function "csinf" : YES
      Checking for function "csinl" : YES
      Checking for function "csinh" : YES (cached)
      Checking for function "csinhf" : YES
      Checking for function "csinhl" : YES
      Checking for function "ccos" : YES (cached)
      Checking for function "ccosf" : YES
      Checking for function "ccosl" : YES
      Checking for function "ccosh" : YES (cached)
      Checking for function "ccoshf" : YES
      Checking for function "ccoshl" : YES
      Checking for function "ctan" : YES (cached)
      Checking for function "ctanf" : YES
      Checking for function "ctanl" : YES
      Checking for function "ctanh" : YES (cached)
      Checking for function "ctanhf" : YES
      Checking for function "ctanhl" : YES
      Checking for function "isfinite" : YES
      Checking for function "isinf" : YES
      Checking for function "isnan" : YES
      Checking for function "signbit" : YES
      Checking for function "fallocate" : NO
      Checking for function "strtold_l" : YES
      Checking for function "backtrace" : NO
      Checking for function "madvise" : YES
    
  6. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    Thanks @LukaszMoskala. So the check passes. Something is very badly wrong with those checks, if I look in build/meson-logs/meson-log.txt on Linux I see:

    Running compile:
    Working directory:  /home/rgommers/code/numpy/build/meson-private/tmpgkbtw7os
    Code:
     
            #define ccosl meson_disable_define_of_ccosl
            
            #include <limits.h>
            #undef ccosl
            
            #ifdef __cplusplus
            extern "C"
            #endif
            char ccosl (void);
            
            #if defined __stub_ccosl || defined __stub___ccosl
            fail fail fail this function is not going to work
            #endif
            
            int main(void) {
              return ccosl ();
            }
    -----------
    Command line: `/home/rgommers/mambaforge/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -L/home/rgommers/mambaforge/envs/numpy-dev/lib /home/rgommers/code/numpy/build/meson-private/tmpgkbtw7os/testfile.c -o /home/rgommers/code/numpy/build/meson-private/tmpgkbtw7os/output.exe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -D_FILE_OFFSET_BITS=64 -O0 -std=c99 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/rgommers/mambaforge/envs/numpy-dev/lib -Wl,-rpath-link,/home/rgommers/mambaforge/envs/numpy-dev/lib` -> 1
    stderr:
    /home/rgommers/code/numpy/build/meson-private/tmpgkbtw7os/testfile.c:10:14: warning: conflicting types for built-in function 'ccosl'; expected '_Complex long double(_Complex long double)' [-Wbuiltin-declaration-mismatch]
       10 |         char ccosl (void);
          |              ^~~~~
    /home/rgommers/code/numpy/build/meson-private/tmpgkbtw7os/testfile.c:5:1: note: 'ccosl' is declared in header '<complex.h>'
        4 |         #include <limits.h>
      +++ |+#include <complex.h>
        5 |         #undef ccosl
    /home/rgommers/mambaforge/envs/numpy-dev/bin/../lib/gcc/x86_64-conda-linux-gnu/11.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/ccQflKnA.o: in function `main':
    testfile.c:(.text.main+0x6): undefined reference to `ccosl'
    collect2: error: ld returned 1 exit status
    

    but the check passes!

    Once I improve the check by adding the missing complex.h include:

    --- a/numpy/core/meson.build
    +++ b/numpy/core/meson.build
    @@ -181,7 +181,7 @@ foreach func: c99_complex_funcs
       if cc.has_function(func_single)
         cdata.set10('HAVE_' + func_single.to_upper(), true)
       endif
    -  if cc.has_function(func_longdouble)
    +  if cc.has_function(func_longdouble, prefix: '#include <complex.h>')
         cdata.set10('HAVE_' + func_longdouble.to_upper(), true)
       endif
     endforeach

    it starts failing with:

    Running compile:
    Working directory:  /home/rgommers/code/numpy/build/meson-private/tmppjsv4dqy
    Code:
     #include <complex.h>
    #include <limits.h>
    
            #if defined __stub_ccosl || defined __stub___ccosl
            fail fail fail this function is not going to work
            #endif
            
    int main(void) {
                void *a = (void*) &ccosl;
                long long b = (long long) a;
                return (int) b;
            }
    -----------
    Command line: `/home/rgommers/mambaforge/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -L/home/rgommers/mambaforge/envs/numpy-dev/lib /home/rgommers/code/numpy/build/meson-private/tmppjsv4dqy/testfile.c -o /home/rgommers/code/numpy/build/meson-private/tmppjsv4dqy/output.exe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -D_FILE_OFFSET_BITS=64 -O0 -std=c99 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/rgommers/mambaforge/envs/numpy-dev/lib -Wl,-rpath-link,/home/rgommers/mambaforge/envs/numpy-dev/lib` -> 1
    stderr:
    /home/rgommers/mambaforge/envs/numpy-dev/bin/../lib/gcc/x86_64-conda-linux-gnu/11.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/ccAXOZ80.o: in function `main':
    testfile.c:(.text.main+0x7): undefined reference to `ccosl'
    collect2: error: ld returned 1 exit status
    

    Okay, way more is broken here with the cc.has_function checks, it just happens to work in our CI because we don't test anything on a non-C99-complete platform. This needs fixing asap.

    Reacted by GalaxySnail
  7. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    The correct invocation is:

    if cc.has_function(func_longdouble, prefix: '#include <complex.h>', dependencies: m_dep)

    Which results in the function being detected and the output being clean:

    Running compile:
    Working directory:  /home/rgommers/code/numpy/build/meson-private/tmpbqbui5ef
    Code:
     #include <complex.h>
    #include <limits.h>
    
            #if defined __stub_ccosl || defined __stub___ccosl
            fail fail fail this function is not going to work
            #endif
            
    int main(void) {
                void *a = (void*) &ccosl;
                long long b = (long long) a;
                return (int) b;
            }
    -----------
    Command line: `/home/rgommers/mambaforge/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -L/home/rgommers/mambaforge/envs/numpy-dev/lib /home/rgommers/code/numpy/build/meson-private/tmpbqbui5ef/testfile.c -o /home/rgommers/code/numpy/build/meson-private/tmpbqbui5ef/output.exe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgommers/mambaforge/envs/numpy-dev/include -D_FILE_OFFSET_BITS=64 -O0 -std=c99 -Wl,--start-group -lm -Wl,--end-group -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/rgommers/mambaforge/envs/numpy-dev/lib -Wl,-rpath-link,/home/rgommers/mambaforge/envs/numpy-dev/lib` -> 0
    Checking for function "ccosl" with dependency -lm: YES
    
  8. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    Upstream issues:

    • False positive in has_function() mesonbuild/meson#3740
    • has_function finds compiler builtins mesonbuild/meson#7652
    • Check for conditionally-inlined compiler builtins mesonbuild/meson#10674

    The problem is that if the check is wrong, Meson tries to detect the __builtin variant and that may then succeed even if the OS doesn't provide an implementation.

    Reacted by GalaxySnail
  9. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    Part of the problem here is that a generic has_function implementation isn't going to have the correct prototype for the function, which (according to this comment), makes the __has_builtin check problematic. Better to have explicit prototypes - we had those in the setup.py build (inside feature_detection_math.h & co). I guess we should revive those headers - also good for making the configure checks faster.

  10. rgommers
    added a commit that references this issue on Oct 7, 2023

    BLD: fix incorrect feature checks for mandatory math functions

    This issue will close once commit 8f161c4 is merged into the 'main' branch.
    8f161c4
  11. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    @LukaszMoskala I think gh-24876 will fix this - could you please check if that works for you?

  12. LukaszMoskala commented on Oct 7, 2023

    @LukaszMoskala
    LukaszMoskala
    on Oct 7, 2023
    Author
    More actions

    With your fix I get diffrent error:

    >>> import numpy as np
    Traceback (most recent call last):
      File "/usr/home/homeassistant/hass_venv2/lib/python3.11/site-packages/numpy/core/__init__.py", line 24, in <module>
        from . import multiarray
      File "/usr/home/homeassistant/hass_venv2/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in <module>
        from . import overrides
      File "/usr/home/homeassistant/hass_venv2/lib/python3.11/site-packages/numpy/core/overrides.py", line 8, in <module>
        from numpy.core._multiarray_umath import (
    ImportError: /usr/home/homeassistant/hass_venv2/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311.so: Undefined symbol "_npy_scaled_cexpl"
    ...
    

    I used pip install git+https://github.com/rgommers/numpy.git@fix-math-featurechecks, please correct me if that's wrong.

    The same error appears when using numpy installed using pip install git+https://github.com/numpy/numpy.git@main so that may be unrelated (or I'm doing something very wrong)

    I'll try applying your patch on 1.26.0

  13. LukaszMoskala commented on Oct 7, 2023

    @LukaszMoskala
    LukaszMoskala
    on Oct 7, 2023
    Author
    More actions

    After applying your patch on 1.26.0 error changes to:

          [47/495] Compiling C object numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o
          FAILED: numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o
          cc -Inumpy/core/libnpymath.a.p -Inumpy/core -I../../numpy/core -Inumpy/core/include -I../../numpy/core/include -I../../numpy/core/src/npymath -I../../numpy/core/src/common -I/usr/local/include/python3.11 -I/tmp/pip-req-build-guz96q3r/.mesonpy-3eoroqew/build/meson_cpu -fcolor-diagnostics -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -O3 -fno-strict-aliasing -ftrapping-math -DNPY_HAVE_CLANG_FPSTRICT -msse -msse2 -msse3 -DNPY_HAVE_SSE2 -DNPY_HAVE_SSE -DNPY_HAVE_SSE3 -fPIC -MD -MQ numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o -MF numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o.d -o numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o -c numpy/core/libnpymath.a.p/npy_math_complex.c
          ../../numpy/core/src/npymath/npy_math_complex.c.src:635:17: warning: implicit declaration of function '_npy_scaled_cexpl' is invalid in C99 [-Wimplicit-function-declaration]
                      z = _npy_scaled_cexpl(absx, y, -1);
                          ^
          ../../numpy/core/src/npymath/npy_math_complex.c.src:635:15: error: assigning to 'npy_clongdouble' from incompatible type 'int'
                      z = _npy_scaled_cexpl(absx, y, -1);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          ../../numpy/core/src/npymath/npy_math_complex.c.src:777:17: warning: implicit declaration of function '_npy_scaled_cexpl' is invalid in C99 [-Wimplicit-function-declaration]
                      z = _npy_scaled_cexpl(absx, y, -1);
                          ^
          ../../numpy/core/src/npymath/npy_math_complex.c.src:777:15: error: assigning to 'npy_clongdouble' from incompatible type 'int'
                      z = _npy_scaled_cexpl(absx, y, -1);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          2 warnings and 2 errors generated.
    

    It's still possible that I'm doing something very wrong

  14. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    I used pip install git+https://github.com/rgommers/numpy.git@fix-math-featurechecks, please correct me if that's wrong.

    I think that that works, although I am not 100% sure about pip checking out git submodules correctly (by network is very slow right now, so hard to check). I'd normally clone the repo, then run git submodule update --init and then check out the desired branch. That's a lot more efficient anyway when testing more than once, because pointing pip at GitHub directly will clone into a tmpdir and then throw everything away.

    Undefined symbol "_npy_scaled_cexpl"

    I don't quite understand what the problem there is. The _npy_scaled_cexpl function should be defined when the same HAVE_CEXPL macro is not defined as used for npy_cexpl:

    numpy/numpy/core/src/npymath/npy_math_complex.c.src

    Lines 166 to 199 in 195d85b

    #if !defined(HAVE_CEXP@C@)
    static
    @ctype@
    _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
    {
    #if @precision@ == 1
    const npy_int k = 235;
    #endif
    #if @precision@ == 2
    const npy_int k = 1799;
    #endif
    #if @precision@ == 3
    const npy_int k = 19547;
    #endif
    const @type@ kln2 = k * NPY_LOGE2@c@;
    @type@ mant, mantcos, mantsin;
    npy_int ex, excos, exsin;
    mant = npy_frexp@c@(npy_exp@c@(x - kln2), &ex);
    mantcos = npy_frexp@c@(npy_cos@c@(y), &excos);
    mantsin = npy_frexp@c@(npy_sin@c@(y), &exsin);
    expt += ex + k;
    return npy_cpack@c@( npy_ldexp@c@(mant * mantcos, expt + excos),
    npy_ldexp@c@(mant * mantsin, expt + exsin));
    }
    #endif
    #ifndef HAVE_CEXP@C@
    @ctype@
    npy_cexp@c@(@ctype@ z)

    With a local patch I can ensure HAVE_CEXP* remains undefined, and I then get the expected symbols in libnpymath.a (and that is linked into multiarray_umath.so):

    $ nm  build-install/usr/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a | rg scaled
    0000000000000000 t _npy_scaled_cexp
    0000000000000000 t _npy_scaled_cexpf
    0000000000000000 t _npy_scaled_cexpl
    
    $ nm  build-install/usr/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a | rg npy_cexp
    0000000000000000 T npy_cexp
    0000000000000000 T npy_cexpf
    0000000000000000 T npy_cexpl
    

    Could you post your full build log (in a gist if it's too large)?

  15. LukaszMoskala commented on Oct 7, 2023

    @LukaszMoskala
    LukaszMoskala
    on Oct 7, 2023
    Author
    More actions

    Sure, here it is.
    Also I'll try python 3.9
    Edit: Exactly the same thing happens on python3.9

  16. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    Thanks. It looks like that fixed the checks, because csinl and ccosl are now correctly reported as NO:

      Checking for function "cexpl" with dependency -lm: YES
    ...
      Checking for function "csinf" with dependency -lm: YES
      Checking for function "csinl" with dependency -lm: NO
    

    And I see now what's wrong with _npy_scaled_cexpl - it's used from within a #ifndef HAVE_CCOSH@C@ code block, and that is going wrong when HAVE_CEXPL is true and HAVE_CCOSL is false. That's a clear bug in the code, and I think it's there in 1.25.2 as well after some larger reshuffles in npy_math_complex.c.src (or it may always have been there). The switch to Meson may have exposed it by detecting cexpl as available while ccosl/csinl are unavailable - the setup.py build must have seen them all as unavailable.

    I'm going to try to get that CI job going, because there may be more such issues.

  17. rgommers commented on Oct 7, 2023

    @rgommers
    rgommers
    on Oct 7, 2023
    Member
    More actions

    cexpl was actually implemented recently, it landed in FreeBSD 13: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216862. So the feature check results make sense, and this new implementation exposed the bug with _npy_scaled_cexpl.

  18. rgommers
    added a commit that references this issue on Oct 7, 2023

    BLD: fix incorrect feature checks for mandatory math functions

    This issue will close once commit 2e6bfc9 is merged into the 'main' branch.
    2e6bfc9
  19. charris
    closed this as completedin #24876on Oct 7, 2023
  20. charris
    added 3 commits that reference this issue on Oct 7, 2023

    BLD: fix math func feature checks, fix FreeBSD build, add CI job (#24876

    This issue will close once commit 040ed2d is merged into the 'main' branch.
    040ed2d

    BLD: fix math func feature checks, fix FreeBSD build, add CI job (num…

    This issue will close once commit 1d8828b is merged into the 'main' branch.
    1d8828b

    BLD: fix math func feature checks, fix FreeBSD build, add CI job (#24876

    This issue will close once commit c7e073c is merged into the 'main' branch.
    c7e073c
  21. LukaszMoskala commented on Oct 9, 2023

    @LukaszMoskala
    LukaszMoskala
    on Oct 9, 2023
    Author
    More actions

    I just want to leave instructions on backporting this to 1.26.0 for example for homeassistant which currently uses numpy 1.26.0.

    Basically did pip update homeassistant and then:

    # outside of homeassistant venv
    git clone https://github.com/numpy/numpy.git numpy-git
    cd numpy-git
    git checkout v1.26.0
    git cherry-pick 040ed2d
    git submodule update --init
    cd ..
    # now enter homeassistant venv
    pip install numpy-git/

    I hope that this helps someone that needs to use older version with this fix. Also I can confirm that this fix works.

    Thank you @charris and @rgommers for quick fix!

    Reacted by Ralf Gommers, Ryan Winter, Jeremy Boy, Andrew Klaus, tehfink and Saro G.
  22. ryanwinter commented on Oct 10, 2023

    @ryanwinter
    ryanwinter
    on Oct 10, 2023
    More actions

    Thanks @LukaszMoskala, I need this for my home assistant install.

  23. charris
    added a commit that references this issue on Nov 11, 2023

    BLD: fix math func feature checks, fix FreeBSD build, add CI job (num…

    This issue will close once commit 075a94f is merged into the 'main' branch.
    075a94f
  24. Fantmur commented on Nov 13, 2023

    @Fantmur
    Fantmur
    on Nov 13, 2023
    More actions

    Great Thanks @LukaszMoskala,
    For Android Termux :

    outside of homeassistant venv

    git clone https://github.com/numpy/numpy.git numpy-git
    cd numpy-git
    git checkout v1.26.0
    git cherry-pick 040ed2d
    git submodule update --init
    cd ..

    now enter homeassistant venv

    LDFLAGS=" -lm -lpython3" pip install numpy-git/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    32 - InstallationProblems installing or compiling NumPy

    Type

    No type

    Projects

    No projects

      Milestone

      • 1.26.1 release

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.