rom-py / rompy

Relocatable Ocean Modelling in PYthon (rompy) combines templated cookie-cutter model configuration with various xarray extensions to assist in the setup and evaluation of coastal ocean model
https://rom-py.github.io/rompy/
BSD 3-Clause "New" or "Revised" License
3 stars 9 forks source link

Import issues for Numpy version <2 #97

Closed blasee closed 3 months ago

blasee commented 4 months ago

Hey team,

We run a few environments where we have pinned Numpy version <2 (for now) and we're getting import errors for the latest development version of Rompy. Is it possible for Rompy to allow for environments running Numpy version less than 2?

python3.10 -m venv temp_env
source temp_env/bin/activate
pip install rompy
pip install "numpy<2"
pip freeze

pip_freeze.txt

import rompy.swan

traceback.txt

The issue arises due to the latest release of pydantic_numpy (6.0.0), which requires numpy>=2.0.0.

Keep up the great work!

rafa-guedes commented 3 months ago

@blasee I can replicate your problem. If you set numpy<2 inside pyproject.toml, the compatible versions are correctly installed:

numpy==1.26.4 pydantic_numpy==5.0.2

However it is probably better those aren't pinned in rompy itself if we can avoid it. The easiest solution is installing numpy<2 and also pydantic_numpy<6 after you have installed rompy, I have tested it here and it works okay.

blasee commented 3 months ago

Thanks @rafa-guedes. Pinning pydantic_numpy to less than 6 solves this issue.