diff --git a/plotting/roofline.py b/plotting/roofline.py index ea007e4fbc0c0ff7a07232d740da944f087b077f..8d5853f8713ac6c9ad8f407dc19a94fb22086ef5 100644 --- a/plotting/roofline.py +++ b/plotting/roofline.py @@ -1,7 +1,12 @@ import plotly.graph_objs as go from dataclasses import dataclass import json -import importlib + +try: + import importlib.resources as pkg_resources +except ImportError: + # Try backported to PY<37 `importlib_resources`. + import importlib_resources as pkg_resources @dataclass @@ -19,7 +24,7 @@ DEFAULT_MARKER = dict(size=10, color='green') def get_data(file_name="roofline_data.json"): - with importlib.resources.open_text(__package__, file_name) as file: + with pkg_resources.open_text(__package__, file_name) as file: data = json.load(file) return data diff --git a/setup.py b/setup.py index cb90c519e00dc61f57fe69587182ae080c576a92..5103f7cd81b4ae9e94b5ba33442cad44acea8f60 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ setup(name="cb-util", "requests", "plotly", "kaleido", - "kadi-apy" + "kadi-apy", + "importlib_resources ; python_version<'3.7'", ], setup_requires=['pytest-runner'], tests_require=['pytest']