NCAR / wrf-python

A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
https://wrf-python.readthedocs.io
Apache License 2.0
411 stars 155 forks source link

Fixing setup.py (install numpy) #185

Closed kinow closed 2 years ago

kinow commented 2 years ago

Hi,

I noticed that in the last release it had a GitHub Action to deploy to PYPI, but looks like that's still not working (related to #170 & #176).

I imported the project into PyCharm, fixed a couple warnings, and then had the same error from GitHub Actions. In GH Actions, the error is as below.

image

Reproduced locally on a fresh virtual environment.

(venv) kinow@ranma:~/Development/python/workspace/wrf-python$ pip install -e .
Obtaining file:///home/kinow/Development/python/workspace/wrf-python
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/kinow/Development/python/workspace/wrf-python/setup.py", line 16, in <module>
          import numpy.distutils.core
      ModuleNotFoundError: No module named 'numpy'
      Says: None
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

The issue is that we were expecting importlib.util.find_spec('numpy') to raise an error, but since 3.4 (was find_module I believe) it returns None when the module is not found.

image

I simply raised the exception when the module returned is None, and that fixed the installation on my environment. Tested that running the installation again doesn't raise the issue.

Cheers, Bruno

michaelavs commented 2 years ago

Thank you for taking the time to look into this issue! Once CI tests pass I will review your changes and hopefully we will be able to get this merged and ready for a release!