projects/aports·blob master · refs

36 lines · 1.3 KiB

1diff --git a/sassutils/wsgi.py b/sassutils/wsgi.py
2index d29fa824f353..f2232b88232f 100644
3--- a/sassutils/wsgi.py
4+++ b/sassutils/wsgi.py
5@@ -6,7 +6,18 @@ import collections.abc
6 import logging
7 import os.path
8
9-from pkg_resources import resource_filename
10+# For getting resources filenames, we now use importlib.resources
11+from contextlib import ExitStack
12+from sys import version_info
13+
14+# However, we check the Python version in order to still support older
15+# versions which don't support importlib.resources (backwards compatibility)
16+if version_info >= (3, 7):
17+ # Use importlib.resources for Python 3.7 and later
18+ from importlib import resources
19+else:
20+ # Use importlib_resources for Python 3.6 and earlier
21+ import importlib_resources as resources
22
23 from .builder import Manifest
24 from sass import CompileError
25@@ -107,7 +118,9 @@ class SassMiddleware:
26 for package_name in self.manifests:
27 if package_name in self.package_dir:
28 continue
29- path = resource_filename(package_name, '')
30+ ref = resources.files(package_name) / 'resource.dat'
31+ with resources.as_file(ref) as res_path:
32+ path = res_path
33 self.package_dir[package_name] = path
34 self.paths = []
35 for package_name, manifest in self.manifests.items():
36