On Sun, Sep 15, 2024 at 05:07:36PM +0200, Alexandre Detiste wrote: > I'm getting the error "module ‘importlib’ has no attribute ‘find_spec’" > when I try to re-enable tests for voltron; > which is using python3-scruffy for it's build. > > As far as I understand, the sole purpose of python3-scruffy is to build > "voltron".
Hi, I had a go at this today. I _think_ I have something that works and is equivalent to the old imp-based code, but I couldn't get the voltron tests completely working and I'm not sure whether the remainder are bugs in python-scruffy, or in voltron, or in my temporary hacks to voltron. Could you please have a look? All these patches are obviously preliminary; I haven't finalized changelogs or anything. diff --git a/debian/changelog b/debian/changelog index 4d3dcc6..2183a80 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-scruffy (0.3.8.2-2) UNRELEASED; urgency=medium + + * + + -- Colin Watson <cjwat...@debian.org> Thu, 03 Oct 2024 22:38:08 +0100 + python-scruffy (0.3.8.2-1) unstable; urgency=medium * Team upload. diff --git a/debian/patches/0001-Migrate-from-imp-to-importlib.patch b/debian/patches/0001-Migrate-from-imp-to-importlib.patch index 9e9188f..89c0e55 100644 --- a/debian/patches/0001-Migrate-from-imp-to-importlib.patch +++ b/debian/patches/0001-Migrate-from-imp-to-importlib.patch @@ -1,32 +1,38 @@ From: Dale Richards <d...@dalerichards.net> Date: Mon, 25 Dec 2023 21:41:37 +0000 Subject: Migrate from imp to importlib -Forwarded: https://github.com/snare/scruffy/pull/31 +Forwarded: https://github.com/snare/scruffy/pull/31 --- - scruffy/plugin.py | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) + scruffy/plugin.py | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) +diff --git a/scruffy/plugin.py b/scruffy/plugin.py +index 9c6853b..6f556f0 100644 --- a/scruffy/plugin.py +++ b/scruffy/plugin.py -@@ -5,7 +5,7 @@ +@@ -5,7 +5,8 @@ Plugin Classes for representing and loading plugins. """ import os -import imp -+import importlib ++import importlib.machinery ++import importlib.util import six -@@ -56,9 +56,9 @@ +@@ -56,9 +57,11 @@ class PluginManager(object): # if it's a file, load it modname, ext = os.path.splitext(filename) if os.path.isfile(filepath) and ext == '.py': - file, path, descr = imp.find_module(modname, [directory]) -+ file, path, descr = importlib.find_spec(modname, [directory]) - if file: +- if file: - mod = imp.load_module(modname, file, path, descr) -+ mod = importlib.load_module(modname, file, path, descr) ++ loader = importlib.machinery.SourceFileLoader(modname, filepath) ++ spec = importlib.util.spec_from_loader(modname, loader) ++ if spec: ++ mod = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(mod) # if it's a directory, recurse into it if os.path.isdir(filepath): And just a rough patch to get voltron running any tests at all (that setting of HOME is obviously crude, and I don't expect we'd want to go back to using nose - I just wanted something that presumably worked at some point): diff --git a/debian/changelog b/debian/changelog index b84069a..11ea1c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +voltron (0.1.7+git20200109-5) UNRELEASED; urgency=medium + + * + + -- Colin Watson <cjwat...@debian.org> Thu, 03 Oct 2024 21:52:17 +0100 + voltron (0.1.7+git20200109-4) unstable; urgency=medium * Team upload. diff --git a/debian/control b/debian/control index fc82489..e5854c2 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,9 @@ Build-Depends: debhelper-compat (= 13), python3-flask-restful, python3-flask, python3-mock, + python3-nose, python3-pexpect, + python3-pygments, python3-requests-unixsocket, python3-scruffy, python3-setuptools, diff --git a/debian/rules b/debian/rules index 8c3f952..48188ff 100755 --- a/debian/rules +++ b/debian/rules @@ -9,6 +9,5 @@ execute_before_dh_auto_configure: cat debian/*manpages | sed 's/$$/.txt/p' | xargs -n 1 a2x --doctype manpage --format manpage override_dh_auto_test: - # The test needs home directory, so we disable it. - #python3 -m nose -sv tests/gdb_cli_tests.py - #python3 -m nose -sv tests/lldb_cli_tests.py + HOME=$(CURDIR)/debian python3 -m nose -sv tests/gdb_cli_tests.py + HOME=$(CURDIR)/debian python3 -m nose -sv tests/lldb_cli_tests.py Thanks, -- Colin Watson (he/him) [cjwat...@debian.org]