You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: NumPy 2.2.0rc1 import fails with PYTHONOPTIMIZE=2 #27866
A build failure was observed per scipy/scipy#21957 for this particular SciPy build incantation: python -m build --wheel --no-isolation -Ccompile-args=-j32
I bisected to the NumPy commit below. Is this a bug in NumPy or something we need to adjust downstream? @mhvk and @seberg were the PR reviewers.
b47bd25e3caba52321a6ba420650fc0eff97f473 is the first bad commit
commit b47bd25e3caba52321a6ba420650fc0eff97f473
Author: Clément Robert <[email protected]>
Date: Fri Nov 22 11:56:31 2024 +0100
API: register NEP 35 functions as array_functions (#27490)
Register `like=` functions as array-functions. This is currently decided based on finding the magic `${ARRAY_FUNCTION_LIKE}` string in the documentation.
Close gh-27451
Whoa, my reproducer on x86_64 Linux is pretty simple with Python 3.10:
importnumpyasnp
pip install -U --pre numpy
python probe.py
Traceback (most recent call last):
File "/home/treddy/rough_work/numpy/issue_27866/probe.py", line 1, in <module>
import numpy as np
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/__init__.py", line 114, in <module>
from numpy.__config__ import show as show_config
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/__config__.py", line 4, in <module>
from numpy._core._multiarray_umath import (
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/_core/__init__.py", line 74, in <module>
from . import numeric
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/_core/numeric.py", line 139, in <module>
def ones(shape, dtype=None, order='C', *, device=None, like=None):
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/_core/overrides.py", line 28, in finalize_array_function_like
public_api.__doc__ = get_array_function_like_doc(public_api)
File "/home/treddy/python_venvs/py_310_scipy/lib/python3.10/site-packages/numpy/_core/overrides.py", line 25, in get_array_function_like_doc
return docstring.replace("${ARRAY_FUNCTION_LIKE}", array_function_like_doc)
AttributeError: 'NoneType' object has no attribute 'replace'
changed the title [-]BUG: SciPy build failure against NumPy 2.2.0rc1[/-][+]BUG: SciPy build failure against NumPy 2.2.0rc1 (Python 3.10)[/+]on Nov 26, 2024
How strange, Ubuntu 22.04 seems common between my machine and the failing CI, but when I play with Python 3.10 on other Linux OS' I don't reproduce. Or maybe I'm just crazy, this is a weird one.
Edit: to be clear, the problem seems to (amazingly, or is this some known thing??) simplify to a function with a docstring returning None for function._doc__ in the situations where I reproduce...
Might there be some hidden optimization option that removes docstrings (I vaguely recall -O does it?). Regardless, the code should not break on that...
Ah, that's a very reasonable guess, PYTHONOPTIMIZE=2 is only set in the SciPy CI for that one failing job.
When I test locally, the one-line reproducer (import numpy as np) with NumPy main indeed passes in a clean environment with any supported Python version and fails consistently via i.e., PYTHONOPTIMIZE=2 python probe.py.
changed the title [-]BUG: SciPy build failure against NumPy 2.2.0rc1 (Python 3.10)[/-][+]BUG: NumPy 2.2.0rc1 import fails with PYTHONOPTIMIZE=2[/+]on Nov 27, 2024
Activity
tylerjereddy commentedon Nov 26, 2024
Whoa, my reproducer on x86_64 Linux is pretty simple with Python
3.10:pip install -U --pre numpypython probe.py[-]BUG: SciPy build failure against NumPy 2.2.0rc1[/-][+]BUG: SciPy build failure against NumPy 2.2.0rc1 (Python 3.10)[/+]tylerjereddy commentedon Nov 27, 2024
How strange,
Ubuntu 22.04seems common between my machine and the failing CI, but when I play with Python3.10on other Linux OS' I don't reproduce. Or maybe I'm just crazy, this is a weird one.Edit: to be clear, the problem seems to (amazingly, or is this some known thing??) simplify to a function with a docstring returning
Noneforfunction._doc__in the situations where I reproduce...mhvk commentedon Nov 27, 2024
Might there be some hidden optimization option that removes docstrings (I vaguely recall
-Odoes it?). Regardless, the code should not break on that...tylerjereddy commentedon Nov 27, 2024
Ah, that's a very reasonable guess,
PYTHONOPTIMIZE=2is only set in the SciPy CI for that one failing job.When I test locally, the one-line reproducer (
import numpy as np) with NumPymainindeed passes in a clean environment with any supported Python version and fails consistently via i.e.,PYTHONOPTIMIZE=2 python probe.py.[-]BUG: SciPy build failure against NumPy 2.2.0rc1 (Python 3.10)[/-][+]BUG: NumPy 2.2.0rc1 import fails with PYTHONOPTIMIZE=2[/+]rgommers commentedon Nov 27, 2024
Apparently we have a CI coverage gap here. With the fix for this, we should add
PYTHONOPTIMIZE=2to one of the jobs inlinux.yml.@neutrinoceros since this came from gh-27490, would you perhaps be able to have a look at fixing this issue?
neutrinoceros commentedon Nov 27, 2024
Thanks for the ping Ralph. I got a fix ready in gh-27868