From e719567ff1d8ed7cf182e35604cb8475812375de Mon Sep 17 00:00:00 2001 From: Pushkar Kulkarni <pushkar.kulkarni@canonical.com> Date: Sun, 4 Feb 2024 14:42:44 +0530 Subject: [PATCH 1/2] Migrate from imp to importlib The "imp" package let users implement the import statement, that is enabled dynamic loading of Python modules. The "imp" package was deprecated in an earlier version and finally removed in Python 3.12. The Python3 docs recommend moving to package "importlib" as a replacement. --- debian/changelog | 6 ++++ debian/patches/Replace-imp-by-importlib.patch | 31 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 38 insertions(+) create mode 100644 debian/patches/Replace-imp-by-importlib.patch diff --git a/debian/changelog b/debian/changelog index ee04792..44b823e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +glueviz (1.0.1+dfsg-4) unstable; urgency=medium + + * Migrate from package imp to importlib for Python 3.12 (Closes: #1061799) + + -- Pushkar Kulkarni <pushkar.kulkarni@canonical.com> Sun, 04 Feb 2024 14:33:00 +0530 + glueviz (1.0.1+dfsg-3) unstable; urgency=medium * Team upload. diff --git a/debian/patches/Replace-imp-by-importlib.patch b/debian/patches/Replace-imp-by-importlib.patch new file mode 100644 index 0000000..065ed03 --- /dev/null +++ b/debian/patches/Replace-imp-by-importlib.patch @@ -0,0 +1,31 @@ +--- a/glue/config.py ++++ b/glue/config.py +@@ -1,8 +1,10 @@ + import os +-import imp ++import importlib + import sys ++import types + import warnings + from collections import namedtuple ++from importlib.machinery import SourceFileLoader + + from glue.utils import format_choices + +@@ -994,13 +996,14 @@ + Exception, if no module was found + """ + search_order = search_path or _default_search_order() +- result = imp.new_module('config') ++ # Create a new, empty module ++ result = types.ModuleType('config') + + for config_file in search_order: + dir = os.path.dirname(config_file) + try: + sys.path.append(dir) +- config = imp.load_source('config', config_file) ++ config = SourceFileLoader('config', config_file).load_module() + result = config + except IOError: + pass diff --git a/debian/patches/series b/debian/patches/series index 14a4a22..9e89a04 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,4 @@ Install-in-proper-directory-.txt-file.patch Add-Keywords-to-desktop-file.patch Install-under-the-right-directory-the-package-data.patch Pass-int-argument-to-QProgressBar.setValue.patch +Replace-imp-by-importlib.patch -- GitLab From a1e37ff3f259477da4a2225dc97491e15ed64121 Mon Sep 17 00:00:00 2001 From: Pushkar Kulkarni <pushkar.kulkarni@canonical.com> Date: Wed, 7 Feb 2024 14:17:22 +0530 Subject: [PATCH 2/2] Add DEP3 headers --- debian/patches/Replace-imp-by-importlib.patch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/patches/Replace-imp-by-importlib.patch b/debian/patches/Replace-imp-by-importlib.patch index 065ed03..fd5a5a0 100644 --- a/debian/patches/Replace-imp-by-importlib.patch +++ b/debian/patches/Replace-imp-by-importlib.patch @@ -1,3 +1,9 @@ +Author: Pushkar Kulkarni <pushkar.kulkarni@canonical.com> +Description: The "imp" package lets users implement the import statement, + enabling dynamic loading of Python modules. The "imp" package was + deprecated in an earlier version and removed in Python 3.12. The + Python3 docs recommend moving to package "importlib" as a replacement. +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1061799 --- a/glue/config.py +++ b/glue/config.py @@ -1,8 +1,10 @@ -- GitLab