epics-base / p4p

Python bindings for the PVAccess network client and server.
BSD 3-Clause "New" or "Revised" License
27 stars 38 forks source link

Binary mismatch between p4p 4.1.5 + numpy 1.24.2 in Python 3.8 #102

Open AlexanderWells-diamond opened 1 year ago

AlexanderWells-diamond commented 1 year ago

When trying to use numpy 1.24.2 alongside p4p 4.1.5 I see the following two warnings (which pytest is elevating to errors) in my tests:

___________________ ERROR collecting tests/test_pvaccess.py ____________________
Traceback (most recent call last):
  File "/home/eyh46967/dev/PandABlocks-ioc/tests/test_pvaccess.py", line 8, in <module>
    from p4p import Value
  File "/home/eyh46967/dev/PandABlocks-ioc/venv/lib64/python3.8/site-packages/p4p/__init__.py", line 14, in <module>
    from .wrapper import Value, Type
  File "/home/eyh46967/dev/PandABlocks-ioc/venv/lib64/python3.8/site-packages/p4p/wrapper.py", line 5, in <module>
    from . import _p4p
  File "__init__.pxd", line 918, in init p4p._p4p
RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 232 from PyObject
___________________ ERROR collecting tests/test_pvaccess.py ____________________
Traceback (most recent call last):
  File "/home/eyh46967/dev/PandABlocks-ioc/tests/test_pvaccess.py", line 8, in <module>
    from p4p import Value
  File "/home/eyh46967/dev/PandABlocks-ioc/venv/lib64/python3.8/site-packages/p4p/__init__.py", line 14, in <module>
    from .wrapper import Value, Type
  File "/home/eyh46967/dev/PandABlocks-ioc/venv/lib64/python3.8/site-packages/p4p/wrapper.py", line 5, in <module>
    from . import _p4p
  File "src/p4p/_p4p.pyx", line 599, in init p4p._p4p
AttributeError: type object 'p4p._p4p.ClientProvider' has no attribute '__reduce_cython__'

If I downgrade the numpy version to 1.21.6 then this warning disappears. Alternatively, if I upgrade to Python 3.10 this warning also disappears.

Does this mean that p4p has an implicit dependency on a particular numpy version, or is this warning on this version innocuous and can be safely added to an ignore list?

mdavidsaver commented 1 year ago

I have a suspicion that the situation being addressed in https://github.com/numpy/numpy/commit/3a811358830c324b7b6819b88dec4e4bcd91444a is relevant. In particular, the condition for numpy >= 1.22.0 fits into the version range you mention.

At core, I guess my understanding of managing numpy ABI compatibility needs to be revised. Ideally, this would be translated into install_requires=[] for wheel files a la. epicscorelibs.version.abi_requires(). However, I worry that this won't be straightforward, or forward compatible.