From 3c37bea5fb894ae9415982855d863753936e319d Mon Sep 17 00:00:00 2001 From: Antonio Trande Date: Thu, 22 Jun 2023 20:19:31 +0200 Subject: [PATCH] Update patch for Python-3.12| Enable python tests on Power64 builds --- ...c-3.18.5-fix_python312_compatibility.patch | 51 +++++++++++++++++-- petsc.spec | 2 - 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/petsc-3.18.5-fix_python312_compatibility.patch b/petsc-3.18.5-fix_python312_compatibility.patch index 042072b..7071ef1 100644 --- a/petsc-3.18.5-fix_python312_compatibility.patch +++ b/petsc-3.18.5-fix_python312_compatibility.patch @@ -45,10 +45,10 @@ index 7a74fd06d31..bb1c3e62b55 100755 # Check to ensure that the environmental variable PETSC_DIR has been assigned. # MPLCONFIGDIR is needed for matplotlib -diff --git a/src/binding/petsc4py/src/lib/__init__.py b/src/binding/petsc4py/src/lib/__init__.py +diff --git a/src/lib/__init__.py b/src/lib/__init__.py index 85e9daf118e..310334eae21 100644 ---- a/src/binding/petsc4py/src/lib/__init__.py -+++ b/src/binding/petsc4py/src/lib/__init__.py +--- a/src/lib/__init__.py ++++ b/src/lib/__init__.py @@ -13,7 +13,7 @@ This package is a holds all the available variants of the PETSc @@ -110,3 +110,48 @@ index 85e9daf118e..310334eae21 100644 # silence annoying Cython warning warnings.filterwarnings("ignore", message="numpy.dtype size changed") warnings.filterwarnings("ignore", message="numpy.ndarray size changed") +From c36e9c688a542448939d85251c93951e001443de Mon Sep 17 00:00:00 2001 +From: "Jose E. Roman" +Date: Thu, 22 Jun 2023 10:28:53 +0200 +Subject: [PATCH 2/2] script.py: improve portability for python < 3.5 + +--- + config/BuildSystem/script.py | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +diff --git a/config/BuildSystem/script.py b/config/BuildSystem/script.py +index f120d335712..d3305288195 100644 +--- a/config/BuildSystem/script.py ++++ b/config/BuildSystem/script.py +@@ -132,12 +132,23 @@ class Script(logger.Logger): + @staticmethod + def getModule(root, name): + '''Retrieve a specific module from the directory root, bypassing the usual paths''' +- import importlib.util +- +- spec = importlib.util.spec_from_file_location(name, root) +- module = importlib.util.module_from_spec(spec) +- sys.modules[name] = module +- spec.loader.exec_module(module) ++ try: ++ import importlib.util ++ except ImportError: ++ importlib = None ++ import imp ++ ++ if importlib and sys.version_info > (3,4): ++ spec = importlib.util.spec_from_file_location(name, root) ++ module = importlib.util.module_from_spec(spec) # novermin ++ sys.modules[name] = module ++ spec.loader.exec_module(module) ++ else: ++ (fp, pathname, description) = imp.find_module(name, [root]) ++ try: ++ return imp.load_module(name, fp, pathname, description) ++ finally: ++ if fp: fp.close() + + @staticmethod + def importModule(moduleName): +-- +GitLab diff --git a/petsc.spec b/petsc.spec index 202b87f..30bb37a 100644 --- a/petsc.spec +++ b/petsc.spec @@ -13,9 +13,7 @@ # Python binding and its testing %bcond_without python -%ifnarch %{power64} %{arm} %bcond_without pycheck -%endif %global pymodule_name petsc4py %global pymodule_version %{version} #