File: 0003-replace-pkg_resources-with-importlib.patch

package info (click to toggle)
python-activipy 0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 464 kB
  • sloc: python: 1,262; makefile: 171; lisp: 18; sh: 13
file content (47 lines) | stat: -rw-r--r-- 1,583 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From c52c72f26803ffdcaa2a666c452326ef26621521 Mon Sep 17 00:00:00 2001
From: Arthur Diniz <arthurbdiniz@gmail.com>
Date: Tue, 10 Feb 2026 21:12:28 +0000
Subject: [PATCH] Replace deprecated pkg_resources with importlib

pkg_resources has been removed from Setuptools 72.0.0+.

Closes: #12

Origin: upstream, https://patch-diff.githubusercontent.com/raw/w3c-social/activipy/pull/11.patch
Bug: https://github.com/w3c-social/activipy/issues/12
Bug-Debian: https://bugs.debian.org/1125818
---
 activipy/core.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/activipy/core.py b/activipy/core.py
index 47341ae..83ff18f 100644
--- a/activipy/core.py
+++ b/activipy/core.py
@@ -17,9 +17,13 @@
 ##   See the License for the specific language governing permissions and
 ##   limitations under the License.
 
-from pkg_resources import resource_filename
 import copy
 import json
+try:
+    from importlib.resources import files
+except ImportError:
+    # Fallback for Python < 3.9
+    from importlib_resources import files
 
 from pyld import jsonld
 
@@ -129,9 +133,8 @@ def _map_vocabs(self, vocabs):
 
 
 # TODO: Add this one by default
-AS2_CONTEXT_FILE = resource_filename(
-    'activipy', 'activitystreams2-context.jsonld')
-AS2_CONTEXT = json.loads(open(AS2_CONTEXT_FILE, 'r').read())
+AS2_CONTEXT_FILE = files('activipy').joinpath('activitystreams2-context.jsonld')
+AS2_CONTEXT = json.loads(AS2_CONTEXT_FILE.read_text())
 AS2_CONTEXT_URI = (
     "http://www.w3.org/TR/activitystreams-core/activitystreams2-context.jsonld")
 AS2_DEFAULT_URL_MAP = {