File python-ptrace-pr83-importlib.patch of Package python-python-ptrace

From 41f5378bbf4bfa75970d5cc3f6615411cff61a6c Mon Sep 17 00:00:00 2001
From: Stephen Kitt <steve@sk2.org>
Date: Sun, 10 Dec 2023 19:07:27 +0100
Subject: [PATCH] Use importlib instead of imp in setup_cptrace.py

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 setup_cptrace.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/setup_cptrace.py b/setup_cptrace.py
index 8de9d01..f06b792 100755
--- a/setup_cptrace.py
+++ b/setup_cptrace.py
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
+import importlib.util
+
 SOURCES = ['cptrace/cptrace.c']
 
 CLASSIFIERS = [
@@ -17,7 +19,6 @@
 
 
 def main():
-    from imp import load_source
     from os import path
     from sys import argv
 
@@ -29,7 +30,10 @@ def main():
 
     cptrace_ext = Extension('cptrace', sources=SOURCES)
 
-    cptrace = load_source("version", path.join("cptrace", "version.py"))
+    cptrace_spec = importlib.util.spec_from_file_location("version",
+                                                          path.join("cptrace", "version.py"))
+    cptrace = importlib.util.module_from_spec(cptrace_spec)
+    cptrace_spec.loader.exec_module(cptrace)
 
     install_options = {
         "name": cptrace.PACKAGE,
openSUSE Build Service is sponsored by