CLIMADA-project/climada_petals

esmpy behaves strangely in python 3.10 and 3.11

Closed this issue · 2 comments

For a reason beyond me, esmpy must be imported at the very beginning of execution.
Otherwise the esmpy/__init__.py file fails to load with key error on "Author":

...

import sys
msg = ""

if (sys.version_info <= (3,8)):
    # pre Python 3.8, not sure how far yet
    ...
elif (sys.version_info >= (3,8)):
    # this requires Python 3.8 or higher
    import importlib.metadata as ilm
    msg = ilm.metadata("esmpy")
...
__author__ = msg["Author"]

For the time being esmpy is imported in climada_petals/__init__.py. Which is not clean but seems to prevent the problem.

Another flaw of esmpy in python >= 3.10: the .../etc/conda/activate.d/esmpy-activate.bat files are apparently missing.
Hence we'd also need a workaround for Windows installation where the ESMFMKFILE environment variable is set.

The workaround only works around on Windows. 👎