From 98dec8eb822575a0fa14185dc0f45eb30d5b665c Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Mon, 25 Oct 2021 21:31:58 +0200 Subject: [PATCH] Use importlib.resources to load files --- xarray/core/formatting_html.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index 2a480427d4e..41183b91f60 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -2,8 +2,7 @@ from collections import OrderedDict from functools import lru_cache, partial from html import escape - -import pkg_resources +from importlib import resources from .formatting import inline_variable_array_repr, short_data_repr from .options import _get_boolean_with_default @@ -15,7 +14,7 @@ def _load_static_files(): """Lazily load the resource files into memory the first time they are needed""" return [ - pkg_resources.resource_string("xarray", fname).decode("utf8") + resources.files("xarray").joinpath(fname).read_bytes().decode("utf8") for fname in STATIC_FILES ]