pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

py-Uranium: Replace deprecated imp module with importlib



Module Name:	pkgsrc-wip
Committed By:	Atsushi Toyokura <asteria.at%gmail.com@localhost>
Pushed By:	steleto
Date:		Thu Aug 13 15:30:03 2026 +0900
Changeset:	cc469eedbd8b80cfe0a5bd45c48e7cd9eff38e9a

Modified Files:
	py-Uranium/Makefile
	py-Uranium/distinfo
Added Files:
	py-Uranium/patches/patch-UM_PluginRegistry.py

Log Message:
py-Uranium: Replace deprecated imp module with importlib

restrict to python 3.12+ for py-numpy

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=cc469eedbd8b80cfe0a5bd45c48e7cd9eff38e9a

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 py-Uranium/Makefile                           |  2 +-
 py-Uranium/distinfo                           |  1 +
 py-Uranium/patches/patch-UM_PluginRegistry.py | 53 +++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)

diffs:
diff --git a/py-Uranium/Makefile b/py-Uranium/Makefile
index 5c0f651711..483ecd1290 100644
--- a/py-Uranium/Makefile
+++ b/py-Uranium/Makefile
@@ -23,7 +23,7 @@ DEPENDS+=	${PYPKGPREFIX}-qt5-[0-9]*:../../x11/py-qt5
 pre-install:
 	find ${WRKSRC} -type f -name "*.orig" | xargs ${RM}
 
-PYTHON_VERSIONS_ACCEPTED=	311
+PYTHON_VERSIONS_INCOMPATIBLE=	310 311 # py-numpy
 
 PY_PATCHPLIST=YES
 
diff --git a/py-Uranium/distinfo b/py-Uranium/distinfo
index 6246af333e..51269a18f8 100644
--- a/py-Uranium/distinfo
+++ b/py-Uranium/distinfo
@@ -4,3 +4,4 @@ BLAKE2s (Uranium/4.13.0.tar.gz) = eee4afd35928e3d794a53fa107352eacf2fd3684659502
 SHA512 (Uranium/4.13.0.tar.gz) = bba41754670b42eb92826fe1c2380b76afb62d16158c07f960315dbd77c55932d29dff594d71aff8eafc2f58d1aac4a14b0f6fc36a0a352872077b97c0d7f555
 Size (Uranium/4.13.0.tar.gz) = 1072294 bytes
 SHA1 (patch-UM_Platform.py) = 6bffaa910c2692e2668bd89100daa9484e07ca41
+SHA1 (patch-UM_PluginRegistry.py) = 87d44221d4092d6988627e3456c0920d1d66f8d3
diff --git a/py-Uranium/patches/patch-UM_PluginRegistry.py b/py-Uranium/patches/patch-UM_PluginRegistry.py
new file mode 100644
index 0000000000..fe41188d5d
--- /dev/null
+++ b/py-Uranium/patches/patch-UM_PluginRegistry.py
@@ -0,0 +1,53 @@
+$NetBSD$
+
+Replace deprecated imp module with importlib.
+
+From e86d717035af317dab5d62851181873ec3c38ebe Mon Sep 17 00:00:00 2001
+
+--- UM/PluginRegistry.py.orig	2022-01-10 15:38:09.000000000 +0000
++++ UM/PluginRegistry.py
+@@ -1,11 +1,13 @@
+-# Copyright (c) 2021 Ultimaker B.V.
++# Copyright (c) 2023 UltiMaker
+ # Uranium is released under the terms of the LGPLv3 or higher.
+ 
+-import imp
++import importlib.util
++import importlib.machinery
+ import json
+ import os
+ import shutil  # For deleting plugin directories;
+ import stat  # For setting file permissions correctly;
++import sys
+ import time
+ import types
+ import zipfile
+@@ -684,7 +686,10 @@ class PluginRegistry(QObject):
+             except:
+                 pass
+         try:
+-            file, path, desc = imp.find_module(plugin_id, [final_location])
++            spec = importlib.machinery.PathFinder().find_spec(plugin_id, [final_location])
++            if len(spec.submodule_search_locations) != 1:
++                raise IndexError(f"Attempt to load plugin '{plugin_id}' from {len(spec.submodule_search_locations)} locations.")
++            path = spec.submodule_search_locations[0]
+         except Exception:
+             Logger.logException("e", "Import error when importing %s", plugin_id)
+             return None
+@@ -705,13 +710,12 @@ class PluginRegistry(QObject):
+                 return None
+ 
+         try:
+-            module = imp.load_module(plugin_id, file, path, desc) #type: ignore #MyPy gets the wrong output type from imp.find_module for some reason.
++            module = importlib.util.module_from_spec(spec)
++            sys.modules[plugin_id] = module
++            spec.loader.exec_module(module)
+         except Exception:
+             Logger.logException("e", "Import error loading module %s", plugin_id)
+             return None
+-        finally:
+-            if file:
+-                os.close(file) #type: ignore #MyPy gets the wrong output type from imp.find_module for some reason.
+         self._found_plugins[plugin_id] = module
+         return module
+ 


Home | Main Index | Thread Index | Old Index