From: RuinedYourLife Date: Tue, 30 Jun 2026 10:51:34 +0000 Subject: Remove pkg_resources Origin: backport, https://code.launchpad.net/~ruinedyourlife/launchpadlib/+git/launchpadlib/+merge/507495 Bug-Debian: https://bugs.debian.org/1147419 Last-Update: 2026-09-15 --- setup.py | 1 + src/launchpadlib/testing/resources.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a041cb6..e330109 100755 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ install_requires = [ "httplib2", "lazr.restfulclient>=0.14.2", "lazr.uri", + 'importlib_resources; python_version < "3.9"', ] setup( diff --git a/src/launchpadlib/testing/resources.py b/src/launchpadlib/testing/resources.py index 27f5574..dd18a8a 100644 --- a/src/launchpadlib/testing/resources.py +++ b/src/launchpadlib/testing/resources.py @@ -18,7 +18,11 @@ """Resources for use in unit tests with the C{testresources} module.""" -from pkg_resources import resource_string +# Using the backport of importlib.resources for Python 3.8 +try: + from importlib.resources import files +except ImportError: + from importlib_resources import files from testresources import TestResource @@ -40,7 +44,11 @@ def get_application(): global launchpad_testing_application if launchpad_testing_application is None: markup_url = "https://api.launchpad.net/1.0/" - markup = resource_string("launchpadlib.testing", "launchpad-wadl.xml") + markup = ( + files("launchpadlib.testing") + .joinpath("launchpad-wadl.xml") + .read_bytes() + ) launchpad_testing_application = Application(markup_url, markup) return launchpad_testing_application @@ -50,6 +58,8 @@ class FakeLaunchpadResource(TestResource): return FakeLaunchpad( application=Application( "https://api.example.com/testing/", - resource_string("launchpadlib.testing", "testing-wadl.xml"), + files("launchpadlib.testing") + .joinpath("testing-wadl.xml") + .read_bytes(), ) )