casacore / python-casacore

Python bindings for casacore, a library used in radio astronomy
http://casacore.github.io/python-casacore
GNU Lesser General Public License v3.0
35 stars 22 forks source link

Linux binary wheels don't work with numpy<1.16.0 #184

Closed bmerry closed 4 years ago

bmerry commented 5 years ago

With python-casacore 3.1.1 installed from a binary wheel and numpy 1.15.4 on Ubuntu 18.04 x86_64, I get the following error when trying to load a table (note: the error only happens when trying to open the table, not on import):

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):
  File "./loadms.py", line 4, in <module>
    table('/home/bmerry/work/sdp/experiments/imaging/simple.ms')
  File "/home/bmerry/work/sdp/env3/lib/python3.6/site-packages/casacore/tables/table.py", line 372, in __init__
    Table.__init__(self, tabname, lockopt, opt)
RuntimeError: PycArray: failed to load the numpy API

Upgrading to numpy 1.16.0 or above fixes it. I'm not sure if this is a source-level dependency on numpy or an ABI thing. Possibly building the wheel against an older numpy would improve compatibility (or possibly it will just break newer versions of numpy).

bmerry commented 5 years ago

This bit of the numpy docs seems relevant: https://docs.scipy.org/doc/numpy/reference/c-api.array.html?highlight=import_array#checking-the-api-version

If you want to supported many different numpy versions with one extension binary, you have to build your extension with the lowest NPY_FEATURE_VERSION as possible.

It looks like NPY_FEATURE_VERSION (aka NPY_API_VERSION) was bumped in 1.16.0, so it's expected that wheels built against it won't work against older versions of numpy.