Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NumPy emits ImportWarning when importing numpy.random on PyPy3.9 wh #5413

Closed
mattip opened this issue May 1, 2023 · 1 comment · Fixed by #5414
Closed

[BUG] NumPy emits ImportWarning when importing numpy.random on PyPy3.9 wh #5413

mattip opened this issue May 1, 2023 · 1 comment · Fixed by #5414

Comments

@mattip
Copy link
Contributor

mattip commented May 1, 2023

Describe the bug

$ pypy3.9 -Werror -c "import numpy"
numpy/__init__.py:152: in <module>
    from . import random
numpy/random/__init__.py:180: in <module>
    from . import _pickle
numpy/random/_pickle.py:1: in <module>
    from .mtrand import RandomState
numpy/random/mtrand.pyx:19: in init numpy.random.mtrand
    ???
E   ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

The code imports another cython c-extension module from inside a cython c-extension module.

Code to reproduce the behaviour:

The exception points to this

from ._mt19937 import MT19937 as _MT19937

Expected behaviour

Without -Werror the import works, so it is "just" the warning that is problematic.

OS

Ubuntu 22.04

Python version

pypy3.10 (pre-release), pypy3.9

Cython version

from 0.29.31 to HEAD

Additional context

Maybe need to extend #4764 to more cases? I think this might have to do with the CYTHON_PEP489_MULTI_PHASE_INIT=0 for PyPy. If I define it to 1 the warning goes away and NumPy tests pass. I couldn't easily grep for an existing test for importing another module within a module, but there must be one.

@da-woods
Copy link
Contributor

da-woods commented May 1, 2023

If CYTHON_PEP489_MULTI_PHASE_INIT now works on PyPy then we should enable it.

(Not sure of the rest of the issue)

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

Successfully merging a pull request may close this issue.

3 participants