1From e2372bbecdf46a100b09126f2951431c1929637b Mon Sep 17 00:00:00 2001 2From: Adam Duskett <adam.duskett@amarulasolutions.com> 3Date: Tue, 24 Oct 2023 08:59:21 +0200 4Subject: [PATCH] Replace imp 5 6The imp module has been removed in python 3.12.0. 7 8This change has also been tested with Python 3.9.2 on Debian 11. 9 10From: https://docs.python.org/3.12/whatsnew/3.12.html#removed, follow the 11instructions to add the load_source method back into setup.py. 12 13Upstream: https://github.com/gorakhargosh/pathtools/pull/14 14 15Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> 16--- 17 setup.py | 19 ++++++++++++++++--- 18 1 file changed, 16 insertions(+), 3 deletions(-) 19 20diff --git a/setup.py b/setup.py 21index 4718885..1be0315 100644 22--- a/setup.py 23+++ b/setup.py 24@@ -22,12 +22,25 @@ 25 # THE SOFTWARE. 26 27 import os 28-import imp 29+import importlib.util 30+import importlib.machinery 31 from setuptools import setup 32 33 PKG_DIR = 'pathtools' 34-version = imp.load_source('version', 35- os.path.join(PKG_DIR, 'version.py')) 36+ 37+# From: https://docs.python.org/3.12/whatsnew/3.12.html#removed 38+def load_source(modname, filename): 39+ loader = importlib.machinery.SourceFileLoader(modname, filename) 40+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) 41+ module = importlib.util.module_from_spec(spec) 42+ # The module is always executed and not cached in sys.modules. 43+ # Uncomment the following line to cache the module. 44+ # sys.modules[module.__name__] = module 45+ loader.exec_module(module) 46+ return module 47+ 48+version = load_source('version', 49+ os.path.join(PKG_DIR, 'version.py')) 50 51 def read_file(filename): 52 """ 53-- 542.41.0 55 56