File: replace-pkg-resources.patch

package info (click to toggle)
subuser 0.6.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,216 kB
  • sloc: python: 5,204; sh: 380; makefile: 73; javascript: 43
file content (32 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Description: Replace deprecated pkg_resources with importlib.resources
Author: Andreas Tille <tille@debian.org>
Bug-Debian: https://bugs.debian.org/1083788
Last-Update: 2026-01-17

--- a/logic/subuserlib/paths.py
+++ b/logic/subuserlib/paths.py
@@ -7,6 +7,11 @@ Module used for determining non-user-con
 #external imports
 import os
 import inspect
+try:
+    import importlib.resources as importlib_resources
+except ImportError:
+    # For compatibility with older Python versions (< 3.7)
+    import importlib_resources
 #internal imports
 import subuserlib.executablePath as executablePath
 
@@ -36,9 +41,8 @@ def getSubuserDataFile(filename):
   if os.path.exists(dataFile):
     return dataFile
   else:
-    import pkg_resources
-    dataFile = pkg_resources.resource_filename("subuserlib",os.path.join("data",filename))
-    if not os.path.exists(dataFile):
+    ref = importlib_resources.files("subuserlib").joinpath("data", filename)
+    if not ref.is_file():
       exit("Data file does not exist:"+str(dataFile))
     else:
-      return dataFile
+      return str(ref)