Open Kevinello opened 2 months ago
I haven't examined the source code but from my own testing I surmise a couple of things going on here.
First, wrf-python does not play nice with build isolation. If you look up the stack trace you will see "No module named pip"
In my case I am using uv and I disable build isolation with --no-build-isolation and then the legacy installer will complain that I need pip installed, and then it will complain that I need wheel installed, and lastly on Windows without compilers will fail when it attempts to compile (if you have "Microsoft C++ Build Tools" on Windows it should succeed here, or if you are on Linux it should succeed here). However, requiring pip and wheel in your virtual environment is inconvenient and will cause issues with many modern tools that assume the packages can be installed with build isolation.
Second, wrf-python still relies on distutils, deprecated after numpy 1.23 and fully removed in 1.26. So to even get as far as the above suggestion will get, you need to install numpy<1.26
I would also say that #42 precompiled wheels issues open since 2017 would likely resolve these issues
I haven't examined the source code but from my own testing I surmise a couple of things going on here.
First, wrf-python does not play nice with build isolation. If you look up the stack trace you will see "No module named pip"
https://github.com/NCAR/wrf-python/blob/cec1f70ceff9e4e051e4e0ed73104c60220ab0eb/setup.py#L14
In my case I am using uv and I disable build isolation with --no-build-isolation and then the legacy installer will complain that I need pip installed, and then it will complain that I need wheel installed, and lastly on Windows without compilers will fail when it attempts to compile (if you have "Microsoft C++ Build Tools" on Windows it should succeed here, or if you are on Linux it should succeed here). However, requiring pip and wheel in your virtual environment is inconvenient and will cause issues with many modern tools that assume the packages can be installed with build isolation.
I thought pip only enabled build isolation if it found pyproject.toml
, has that changed recently?
EDIT: Just re-read the text, using uv instead of pip.
The failure without compilers is expected, wrf-python not putting numpy into setuptools's old setup_requires
is less so, though, as noted above, it will try to install NumPy if not present. It needs NumPy installed before the part of the setup script where it could specify NumPy as a requirement, so there wasn't really a good solution before pyproject.toml
.
EDIT: Workarounds: comment out line 14 of setup.py above, ensure you have numpy, setuptools, and wheel installed in the build environement, and disable build isolation. Alternately, use the pyproject.toml
and the setup.py
changes from #241 to allow build isolation for WRF-python on python<3.12.
Second, wrf-python still relies on distutils, deprecated after numpy 1.23 and fully removed in 1.26. So to even get as far as the above suggestion will get, you need to install numpy<1.26
Specifically on NumPy distutils, which looks like it's around for another year on python 3.11 and will never be on 3.12, so there's an argument for python_requires="<3.12"
in the setup script (#240). This is #217 on this repository.
That link proposes suggestions for migrating the build for python 3.12, specifically meson through meson-python or CMake using scikit-build-core, if anyone wants to try for a PR (#242 for CMake).
Error when i use pip to install wrf-python:
I try to install it through source code referencing to documentation, but it still raised the same error
And i'm 100% percent sure that i have numpy in my virtualenv(created by poetry), and i run
pip install wrf-python
while the virtualenv is activated(in thepoetry shell
)