aports/testing/py3-libsass/pkg_resources.patch
Achill Gilgenast fede1c5c9e testing/py3-libsass: move from community, patch for setuptools 82+
Signed-off-by: Achill Gilgenast <achill@achill.org>
2026-02-15 15:33:41 +01:00

37 lines
1.3 KiB
Diff

diff --git a/sassutils/wsgi.py b/sassutils/wsgi.py
index d29fa824f353..f2232b88232f 100644
--- a/sassutils/wsgi.py
+++ b/sassutils/wsgi.py
@@ -6,7 +6,18 @@ import collections.abc
import logging
import os.path
-from pkg_resources import resource_filename
+# For getting resources filenames, we now use importlib.resources
+from contextlib import ExitStack
+from sys import version_info
+
+# However, we check the Python version in order to still support older
+# versions which don't support importlib.resources (backwards compatibility)
+if version_info >= (3, 7):
+ # Use importlib.resources for Python 3.7 and later
+ from importlib import resources
+else:
+ # Use importlib_resources for Python 3.6 and earlier
+ import importlib_resources as resources
from .builder import Manifest
from sass import CompileError
@@ -107,7 +118,9 @@ class SassMiddleware:
for package_name in self.manifests:
if package_name in self.package_dir:
continue
- path = resource_filename(package_name, '')
+ ref = resources.files(package_name) / 'resource.dat'
+ with resources.as_file(ref) as res_path:
+ path = res_path
self.package_dir[package_name] = path
self.paths = []
for package_name, manifest in self.manifests.items():