csiro-coasts / emsarray

xarray extension that supports EMS model formats
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Allow for python <3.8? #7

Closed blasee closed 2 years ago

blasee commented 2 years ago

Hey @mx-moth,

Thanks again for developing this package. I'm running into the following error when importing emsarray using python 3.7:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_22943/494989257.py in <module>
----> 1 import emsarray
      3 """
      4 
----> 5 import importlib.metadata
      6 
      7 from . import tutorial

ModuleNotFoundError: No module named 'importlib.metadata'

It turns out that importlib only has a metadata submodule starting from python 3.8. The jsonschema package uses the following code to circumvent this issue.

try:
    from importlib import metadata
except ImportError: # for Python<3.8
    import importlib_metadata as metadata

which of course requires the installation of the importlib_metadata package.

Is this something that could be implemented in emsarray too?

sharon-tickell commented 2 years ago

Noting for discussion that Python 3.7 will be EOL in less than 12 months from now (on 2023-06-27)...

I agree we should either support python 3.7 while it is still a supported version OR have a clear statement that we require python>=3.8.

If we're going to support 3.7 properly, though, then that would require downgrading some of the emsarray dependencies, as several of the critical ones have already dropped python 3.7 support:

I'm reluctant to lock ourselves into older versions of things like xarray, as that would mean we can't take advantage of new features in that library as they're released (and also, security scanners get whiny about known vulnerabilities).

@blasee what is your use case for needing python 3.7? Any chance of a platform upgrade at your end?

blasee commented 2 years ago

@sharon-tickell I agree downgrading dependencies is not ideal at all. We certainly have the ability to upgrade python at our end so it seems that's the best option, I didn't quite realise how old 3.7 actually was. I'll close this issue, thanks for your reply!