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

spin test usage in numpy is broken #74

Closed
rgommers opened this issue Jun 12, 2023 · 1 comment · Fixed by #75
Closed

spin test usage in numpy is broken #74

rgommers opened this issue Jun 12, 2023 · 1 comment · Fixed by #75
Assignees
Milestone

Comments

@rgommers
Copy link
Contributor

It's the usual error when trying to run tests from the root of the repo:

$ # cd to the root dir of a clean numpy repo
$ mamba env create -f environment.yml
$ pip install spin
...
Successfully installed spin-0.3

$ spin build
...
$ spin test
Invoking `build` prior to running tests:
$ meson compile -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/rgommers/mambaforge/envs/numpy-dev/bin/ninja -C /home/rgommers/code/numpy/build
ninja: Entering directory `/home/rgommers/code/numpy/build'
[1/1] Generating write_version_file with a custom command
$ meson install --only-changed -C build --destdir ../build-install
$ export PYTHONPATH="/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages"
$ cd /home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages
$ /home/rgommers/mambaforge/envs/numpy-dev/bin/python3.9 -m pytest --rootdir=/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages numpy
ImportError while loading conftest '/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/conftest.py'.
numpy/__init__.py:130: in <module>
    raise ImportError(msg) from e
E   ImportError: Error importing numpy: you should not try to import numpy from
E           its source directory; please exit the numpy source tree, and relaunch
E           your python interpreter from there.

The problem seems to be that the build is actually broken - which is unrelated to spin. But the above traceback is misleading. cd-ing into the install dir shows us the real problem:

$ cd build-install/usr/lib/python3.9/site-packages/
$ python -c "import numpy as np"
Traceback (most recent call last):
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/overrides.py", line 8, in <module>
    from numpy.core._multiarray_umath import (
ImportError: /home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so: undefined symbol: cblas_cdotc_sub

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/__init__.py", line 125, in <module>
    from numpy.__config__ import show as show_config
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/__config__.py", line 4, in <module>
    from numpy.core._multiarray_umath import (
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/home/rgommers/mambaforge/envs/numpy-dev/bin/python"
  * The NumPy version is: "2.0.0.dev0+14.g2f36ac5a6"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so: undefined symbol: cblas_cdotc_sub


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

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/rgommers/code/numpy/build-install/usr/lib/python3.9/site-packages/numpy/__init__.py", line 130, 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.

I'll see if I can fix the build issue. The spin part would be to not swallow the traceback with the root cause here.

@stefanv
Copy link
Member

stefanv commented Jun 12, 2023

I think it's pytest that swallows the exception, but we can import numpy first as a sanity check? I'll add that.

stefanv added a commit to stefanv/spin that referenced this issue Jun 12, 2023
jarrodmillman pushed a commit that referenced this issue Jun 28, 2023
* As a build check, import the library before running tests

Closes #74

* Ignore current directory when doing module import check

This is easiest done on Python >= 3.11, so limit it to those versions.
@jarrodmillman jarrodmillman added this to the 0.4 milestone Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants