Bug 1990360 - numpy fails to build with Python 3.10: OverflowError: complex exponentiation & TypeError: argument of type 'NoneType' is not iterable
Summary: numpy fails to build with Python 3.10: OverflowError: complex exponentiation ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: numpy
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gwyn Ciesla
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10 F35FTBFS
TreeView+ depends on / blocked
 
Reported: 2021-08-05 09:18 UTC by Tomáš Hrnčiar
Modified: 2021-08-05 16:52 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-08-05 16:52:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-08-05 09:18:55 UTC
numpy fails to build with Python 3.10.0rc1.

=================================== FAILURES ===================================
_____________________________ TestCpow.test_scalar _____________________________
self = <numpy.core.tests.test_umath_complex.TestCpow object at 0x7f08eda671c0>
    def test_scalar(self):
        x = np.array([1, 1j,         2,  2.5+.37j, np.inf, np.nan])
        y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j,      2,      3])
        lx = list(range(len(x)))
        # Compute the values for complex type in python
>       p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
lx         = [0, 1, 2, 3, 4, 5]
self       = <numpy.core.tests.test_umath_complex.TestCpow object at 0x7f08eda671c0>
x          = array([1. +0.j  , 0. +1.j  , 2. +0.j  , 2.5+0.37j, inf+0.j  , nan+0.j  ])
y          = array([ 1. +0.j ,  0. +1.j , -0.5+1.5j, -0.5+1.5j,  2. +0.j ,  3. +0.j ])
numpy/core/tests/test_umath_complex.py:376: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.0 = <list_iterator object at 0x7f08eda673d0>
>   p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
E   OverflowError: complex exponentiation
.0         = <list_iterator object at 0x7f08eda673d0>
i          = 4
x          = array([1. +0.j  , 0. +1.j  , 2. +0.j  , 2.5+0.37j, inf+0.j  , nan+0.j  ])
y          = array([ 1. +0.j ,  0. +1.j , -0.5+1.5j, -0.5+1.5j,  2. +0.j ,  3. +0.j ])
numpy/core/tests/test_umath_complex.py:376: OverflowError
_____________________________ TestCpow.test_array ______________________________
self = <numpy.core.tests.test_umath_complex.TestCpow object at 0x7f08eda672e0>
    def test_array(self):
        x = np.array([1, 1j,         2,  2.5+.37j, np.inf, np.nan])
        y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j,      2,      3])
        lx = list(range(len(x)))
        # Compute the values for complex type in python
>       p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
lx         = [0, 1, 2, 3, 4, 5]
self       = <numpy.core.tests.test_umath_complex.TestCpow object at 0x7f08eda672e0>
x          = array([1. +0.j  , 0. +1.j  , 2. +0.j  , 2.5+0.37j, inf+0.j  , nan+0.j  ])
y          = array([ 1. +0.j ,  0. +1.j , -0.5+1.5j, -0.5+1.5j,  2. +0.j ,  3. +0.j ])
numpy/core/tests/test_umath_complex.py:389: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.0 = <list_iterator object at 0x7f08eda66080>
>   p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
E   OverflowError: complex exponentiation
.0         = <list_iterator object at 0x7f08eda66080>
i          = 4
x          = array([1. +0.j  , 0. +1.j  , 2. +0.j  , 2.5+0.37j, inf+0.j  , nan+0.j  ])
y          = array([ 1. +0.j ,  0. +1.j , -0.5+1.5j, -0.5+1.5j,  2. +0.j ,  3. +0.j ])
numpy/core/tests/test_umath_complex.py:389: OverflowError
_________________________________ test_lookfor _________________________________
    @pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
    def test_lookfor():
        out = StringIO()
>       utils.lookfor('eigenvalue', module='numpy', output=out,
                      import_modules=False)
out        = <_io.StringIO object at 0x7f08e9f66d40>
numpy/lib/tests/test_utils.py:16: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
numpy/lib/utils.py:715: in lookfor
    cache = _lookfor_generate_cache(module, import_modules, regenerate)
        import_modules = False
        module     = 'numpy'
        output     = <_io.StringIO object at 0x7f08e9f66d40>
        pydoc      = <module 'pydoc' from '/usr/lib64/python3.10/pydoc.py'>
        regenerate = False
        what       = 'eigenvalue'
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
module = <module 'numpy' from '/builddir/build/BUILD/numpy-1.20.1/build/testenv/lib64/python3.10/site-packages/numpy/__init__.py'>
import_modules = False, regenerate = False
    def _lookfor_generate_cache(module, import_modules, regenerate):
        """
        Generate docstring cache for given module.
    
        Parameters
        ----------
        module : str, None, module
            Module for which to generate docstring cache
        import_modules : bool
            Whether to import sub-modules in packages.
        regenerate : bool
            Re-generate the docstring cache
    
        Returns
        -------
        cache : dict {obj_full_name: (docstring, kind, index), ...}
            Docstring cache for the module, either cached one (regenerate=False)
            or newly generated.
    
        """
        # Local import to speed up numpy's import time.
        import inspect
    
        from io import StringIO
    
        if module is None:
            module = "numpy"
    
        if isinstance(module, str):
            try:
                __import__(module)
            except ImportError:
                return {}
            module = sys.modules[module]
        elif isinstance(module, list) or isinstance(module, tuple):
            cache = {}
            for mod in module:
                cache.update(_lookfor_generate_cache(mod, import_modules,
                                                     regenerate))
            return cache
    
        if id(module) in _lookfor_caches and not regenerate:
            return _lookfor_caches[id(module)]
    
        # walk items and collect docstrings
        cache = {}
        _lookfor_caches[id(module)] = cache
        seen = {}
        index = 0
        stack = [(module.__name__, module)]
        while stack:
            name, item = stack.pop(0)
            if id(item) in seen:
                continue
            seen[id(item)] = True
    
            index += 1
            kind = "object"
    
            if inspect.ismodule(item):
                kind = "module"
                try:
                    _all = item.__all__
                except AttributeError:
                    _all = None
    
                # import sub-packages
                if import_modules and hasattr(item, '__path__'):
                    for pth in item.__path__:
                        for mod_path in os.listdir(pth):
                            this_py = os.path.join(pth, mod_path)
                            init_py = os.path.join(pth, mod_path, '__init__.py')
                            if (os.path.isfile(this_py) and
                                    mod_path.endswith('.py')):
                                to_import = mod_path[:-3]
                            elif os.path.isfile(init_py):
                                to_import = mod_path
                            else:
                                continue
                            if to_import == '__init__':
                                continue
    
                            try:
                                old_stdout = sys.stdout
                                old_stderr = sys.stderr
                                try:
                                    sys.stdout = StringIO()
                                    sys.stderr = StringIO()
                                    __import__("%s.%s" % (name, to_import))
                                finally:
                                    sys.stdout = old_stdout
                                    sys.stderr = old_stderr
                            # Catch SystemExit, too
                            except BaseException:
                                continue
    
                for n, v in _getmembers(item):
                    try:
                        item_name = getattr(v, '__name__', "%s.%s" % (name, n))
                        mod_name = getattr(v, '__module__', None)
                    except NameError:
                        # ref. SWIG's global cvars
                        #    NameError: Unknown C global variable
                        item_name = "%s.%s" % (name, n)
                        mod_name = None
>                   if '.' not in item_name and mod_name:
E                   TypeError: argument of type 'NoneType' is not iterable
StringIO   = <class '_io.StringIO'>
_all       = ['ArrayLike', 'DTypeLike', 'NBitBase']
cache      = {'numpy': ('NumPy\n=====\n\nProvides\n  1. An array object of arbitrary homogeneous items\n  2. Fast mathematical oper... 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4", 'object', 4), ...}
doc        = 'Return a description for the given data type code.\n\nParameters\n----------\nchar : str\n    Data type code.\n\nRetu...ng  :  long precision\nf  :  single precision\ni  :  integer\nh  :  short\nl  :  long integer\nq  :  long long integer'
import_modules = False
index      = 499
inspect    = <module 'inspect' from '/usr/lib64/python3.10/inspect.py'>
item       = <module 'numpy.typing' from '/builddir/build/BUILD/numpy-1.20.1/build/testenv/lib64/python3.10/site-packages/numpy/typing/__init__.py'>
item_name  = None
kind       = 'module'
mod_name   = 'typing'
module     = <module 'numpy' from '/builddir/build/BUILD/numpy-1.20.1/build/testenv/lib64/python3.10/site-packages/numpy/__init__.py'>
n          = 'ArrayLike'
name       = 'numpy.typing'
regenerate = False
seen       = {94747946238064: True, 94747946239616: True, 94747947182736: True, 94747947183696: True, ...}
stack      = [('numpy.ubyte', <class 'numpy.uint8'>), ('numpy.ufunc', <class 'numpy.ufunc'>), ('numpy.uint', <class 'numpy.uint64'>...nt0', <class 'numpy.uint64'>), ('numpy.uint16', <class 'numpy.uint16'>), ('numpy.uint32', <class 'numpy.uint32'>), ...]
v          = typing.Union[int, float, complex, str, bytes, numpy.generic, typing.Sequence[typing.Union[int, float, complex, str, bytes, numpy.generic]], typing.Sequence[typing.Sequence[typing.Any]], numpy.typing._array_like._SupportsArray]
numpy/lib/utils.py:894: TypeError
=========================== short test summary info ============================
FAILED numpy/core/tests/test_umath_complex.py::TestCpow::test_scalar - Overfl...
FAILED numpy/core/tests/test_umath_complex.py::TestCpow::test_array - Overflo...
FAILED numpy/lib/tests/test_utils.py::test_lookfor - TypeError: argument of t...
3 failed, 13174 passed, 79 skipped, 1208 deselected, 23 xfailed in 204.09s (0:03:24)

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/02358886-numpy/

For all our attempts to build numpy with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/numpy/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 is already included in Fedora 35. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.


Note You need to log in before you can comment on or make changes to this bug.