JaGeo / LobsterPy

Package to perform automatic bonding analysis with the program Lobster in the field of computational materials science and quantum chemistry
https://jageo.github.io/LobsterPy/
BSD 3-Clause "New" or "Revised" License
74 stars 27 forks source link

[Bug] NumPy 2.x breaks CI tests #301

Closed DanielYang59 closed 1 month ago

DanielYang59 commented 2 months ago

Summary

NumPy 2.x breaks CI tests in Ubuntu 22.04 LTS, perhaps we need to pin it for now?

To recreate:

git clone https://github.com/JaGeo/LobsterPy.git --depth=1

cd LobsterPy
python3 -m venv venv
source venv/bin/activate
pip install -e '.[tests]'

pytest tests/cli/test_cli.py   # >>> broken tests

# Use `numpy` 1.x fixes this
pip install numpy==1.26  
pytest tests/cli/test_cli.py   # >>> tests are now running

Error log

``` A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/bin/pytest", line 8, in sys.exit(console_main()) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 206, in console_main code = main() File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 159, in main config = _prepareconfig(args, plugins) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 346, in _prepareconfig config = pluginmanager.hook.pytest_cmdline_parse( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall res = hook_impl.function(*args) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1152, in pytest_cmdline_parse self.parse(args) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1501, in parse self._preparse(args, addopts=addopts) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1405, in _preparse self.hook.pytest_load_initial_conftests( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall res = hook_impl.function(*args) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1230, in pytest_load_initial_conftests self.pluginmanager._set_initial_conftests( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 588, in _set_initial_conftests self._try_load_conftest( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 626, in _try_load_conftest self._loadconftestmodules( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 666, in _loadconftestmodules mod = self._importconftest( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 717, in _importconftest mod = import_path( File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/pathlib.py", line 591, in import_path importlib.import_module(module_name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 178, in exec_module exec(co, module.__dict__) File "/home/yanghaoyu/test_lobsterpy/LobsterPy/tests/conftest.py", line 8, in from pymatgen.electronic_structure.cohp import CompleteCohp File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pymatgen/electronic_structure/cohp.py", line 22, in from pymatgen.core.sites import PeriodicSite File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pymatgen/core/__init__.py", line 13, in from pymatgen.core.lattice import Lattice File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pymatgen/core/lattice.py", line 21, in from pymatgen.util.coord import pbc_shortest_vectors File "/home/yanghaoyu/test_lobsterpy/LobsterPy/venv/lib/python3.10/site-packages/pymatgen/util/coord.py", line 15, in from pymatgen.util import coord_cython ImportError while loading conftest '/home/yanghaoyu/test_lobsterpy/LobsterPy/tests/conftest.py'. tests/conftest.py:8: in from pymatgen.electronic_structure.cohp import CompleteCohp venv/lib/python3.10/site-packages/pymatgen/electronic_structure/cohp.py:22: in from pymatgen.core.sites import PeriodicSite venv/lib/python3.10/site-packages/pymatgen/core/__init__.py:13: in from pymatgen.core.lattice import Lattice venv/lib/python3.10/site-packages/pymatgen/core/lattice.py:21: in from pymatgen.util.coord import pbc_shortest_vectors venv/lib/python3.10/site-packages/pymatgen/util/coord.py:15: in from pymatgen.util import coord_cython pymatgen/util/coord_cython.pyx:1: in init pymatgen.util.coord_cython ??? E ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use 'numpy._import_array' to disable if you are certain you don't need it). ```
naik-aakash commented 2 months ago

Hi @DanielYang59 ,Isn't this issue specifically originating from pymatgen? Good idea to pin it though untill it's fixed.

DanielYang59 commented 2 months ago

Hi Aakash thanks for your quick reply :). Yes it looks like so but I'm afraid we have to pin numpy for lobsterpy until it's fixed. https://github.com/JaGeo/LobsterPy/blob/55d8d2e119aa1147166994d57fbdbe10931cc748/pyproject.toml#L31-L35

JaGeo commented 2 months ago

@DanielYang59 sure

JaGeo commented 2 months ago

@DanielYang59 done. We will release a new version as soon we have merged another pull request

DanielYang59 commented 2 months ago

No rush at all! Thanks for the fix and for letting me know :)