Skip to content

spin test usage in numpy is broken #74

@rgommers

Description

@rgommers

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions