UMEP-dev / SuPy

SUEWS that speaks Python
https://supy.readthedocs.io/
GNU General Public License v3.0
13 stars 7 forks source link

use `importlib` to load data files #81

Closed sunt05 closed 1 year ago

sunt05 commented 1 year ago

Describe the issue

os.path.dirname(__file__) is not a good way to load data files. It is not portable and it is not a good way to load data files from a package.

Describe the solution you'd like

from importlib.resources import files is a new feature in Python 3.9. It allows us to load data files from a package.

References

  1. https://docs.python.org/3/library/importlib.html#module-importlib.resources
  2. https://setuptools.pypa.io/en/latest/userguide/datafiles.html#accessing-data-files-at-runtime