Skip to content

Commit

Permalink
Merge pull request #489 from xylar/fix_importlib_resources_py38
Browse files Browse the repository at this point in the history
Fix importlib.resources imports for python 3.8
  • Loading branch information
xylar authored Jan 4, 2023
2 parents 1568715 + 5c1241c commit 7286331
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion conda_package/dev-spec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
python>=3.8
cartopy
dask
geometric_features>=1.0.0,<2.0.0
geometric_features>=1.0.1,<2.0.0
hdf5
importlib_resources
inpoly
jigsaw>=0.9.12
jigsawpy>=0.2.1
Expand Down
10 changes: 7 additions & 3 deletions conda_package/mpas_tools/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from configparser import RawConfigParser, ConfigParser, ExtendedInterpolation
import os
from importlib import resources
import inspect
import sys
import numpy as np
import ast
from io import StringIO
try:
from importlib.resources import files as imp_res_files
except ImportError:
# python<=3.8
from importlib_resources import files as imp_res_files


class MpasConfigParser:
Expand Down Expand Up @@ -83,8 +87,8 @@ def add_from_package(self, package, config_filename, exception=True):
Whether to raise an exception if the config file isn't found
"""
try:
with resources.path(package, config_filename) as path:
self._add(path, user=False)
path = imp_res_files(package) / config_filename
self._add(path, user=False)
except (ModuleNotFoundError, FileNotFoundError, TypeError):
if exception:
raise
Expand Down
3 changes: 2 additions & 1 deletion conda_package/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ requirements:
- python
- cartopy
- dask
- geometric_features >=1.0.0,<2.0.0
- geometric_features >=1.0.1,<2.0.0
- hdf5
- importlib_resources # [py<=38]
- inpoly
- jigsaw >=0.9.12
- jigsawpy >=0.2.1
Expand Down

0 comments on commit 7286331

Please sign in to comment.