Debian Codegraph @

debian/patches/remove-pkg-resources.patch

raw
1 From: RuinedYourLife <[email protected]>
2 Date: Tue, 30 Jun 2026 10:51:34 +0000
3 Subject: Remove pkg_resources
4
5 Origin: backport, https://code.launchpad.net/~ruinedyourlife/launchpadlib/+git/launchpadlib/+merge/507495
6 Bug-Debian: https://bugs.debian.org/1147419
7 Last-Update: 2026-09-15
8 ---
9 setup.py | 1 +
10 src/launchpadlib/testing/resources.py | 16 +++++++++++++---
11 2 files changed, 14 insertions(+), 3 deletions(-)
12
13 diff --git a/setup.py b/setup.py
14 index a041cb6..e330109 100755
15 --- a/setup.py
16 +++ b/setup.py
17 @@ -45,6 +45,7 @@ install_requires = [
18 "httplib2",
19 "lazr.restfulclient>=0.14.2",
20 "lazr.uri",
21 + 'importlib_resources; python_version < "3.9"',
22 ]
23
24 setup(
25 diff --git a/src/launchpadlib/testing/resources.py b/src/launchpadlib/testing/resources.py
26 index 27f5574..dd18a8a 100644
27 --- a/src/launchpadlib/testing/resources.py
28 +++ b/src/launchpadlib/testing/resources.py
29 @@ -18,7 +18,11 @@
30
31 """Resources for use in unit tests with the C{testresources} module."""
32
33 -from pkg_resources import resource_string
34 +# Using the backport of importlib.resources for Python 3.8
35 +try:
36 + from importlib.resources import files
37 +except ImportError:
38 + from importlib_resources import files
39
40 from testresources import TestResource
41
42 @@ -40,7 +44,11 @@ def get_application():
43 global launchpad_testing_application
44 if launchpad_testing_application is None:
45 markup_url = "https://api.launchpad.net/1.0/"
46 - markup = resource_string("launchpadlib.testing", "launchpad-wadl.xml")
47 + markup = (
48 + files("launchpadlib.testing")
49 + .joinpath("launchpad-wadl.xml")
50 + .read_bytes()
51 + )
52 launchpad_testing_application = Application(markup_url, markup)
53 return launchpad_testing_application
54
55 @@ -50,6 +58,8 @@ class FakeLaunchpadResource(TestResource):
56 return FakeLaunchpad(
57 application=Application(
58 "https://api.example.com/testing/",
59 - resource_string("launchpadlib.testing", "testing-wadl.xml"),
60 + files("launchpadlib.testing")
61 + .joinpath("testing-wadl.xml")
62 + .read_bytes(),
63 )
64 )