[Debichem-devel] Bug#1061277: abinit: FTBFS with Python 3.12
Steve Langasek
steve.langasek at canonical.com
Mon Jan 22 02:30:49 GMT 2024
Package: abinit
Followup-For: Bug #1061277
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch
Control: tags -1 patch
Dear maintainers,
Please find attached a patch that fixes the build failure with python 3.12.
This change has been uploaded to Ubuntu for the python 3.12 transition.
Thanks for considering,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer https://www.debian.org/
slangasek at ubuntu.com vorlon at debian.org
-------------- next part --------------
diff -Nru abinit-9.10.4/debian/patches/python3.12.patch abinit-9.10.4/debian/patches/python3.12.patch
--- abinit-9.10.4/debian/patches/python3.12.patch 1969-12-31 16:00:00.000000000 -0800
+++ abinit-9.10.4/debian/patches/python3.12.patch 2024-01-21 14:12:54.000000000 -0800
@@ -0,0 +1,65 @@
+Description: Compatibility with python 3.12
+ SafeConfigParser and the imp module are obsoleted in python3.
+Author: Steve Langasek <steve.langasek at ubuntu.com>
+Last-Update: 2024-01-21
+Forwarded: no
+
+Index: abinit-9.10.4/tests/pymods/jobrunner.py
+===================================================================
+--- abinit-9.10.4.orig/tests/pymods/jobrunner.py
++++ abinit-9.10.4/tests/pymods/jobrunner.py
+@@ -11,7 +11,7 @@
+ from ConfigParser import SafeConfigParser, NoOptionError
+ except ImportError:
+ # The ConfigParser module has been renamed to configparser in Python 3
+- from configparser import SafeConfigParser, NoOptionError
++ from configparser import ConfigParser as SafeConfigParser, NoOptionError
+
+ import logging
+ logger = logging.getLogger(__name__)
+Index: abinit-9.10.4/fkiss/project.py
+===================================================================
+--- abinit-9.10.4.orig/fkiss/project.py
++++ abinit-9.10.4/fkiss/project.py
+@@ -422,7 +422,7 @@
+ def filter_fortran(files):
+ return [f for f in files if f.endswith(".f") or f.endswith(".F90")]
+
+- import imp
++ from importlib.machinery import SourceFileLoader
+ name2path = OrderedDict()
+ for d in self.dirpaths:
+ if os.path.basename(d) == "98_main":
+@@ -434,7 +434,7 @@
+ else:
+ # Get source files from abinit.src.
+ abinit_src = os.path.join(d, "abinit.src")
+- mod = imp.load_source(abinit_src, abinit_src)
++ mod = SourceFileLoader("abinit.src", abinit_src).load_module()
+ for basename in filter_fortran(mod.sources):
+ if basename in name2path:
+ raise RuntimeError("Found two Fortran files with same basename `%s` and other in dir `%s`\n"
+Index: abinit-9.10.4/tests/__init__.py
+===================================================================
+--- abinit-9.10.4.orig/tests/__init__.py
++++ abinit-9.10.4/tests/__init__.py
+@@ -7,7 +7,7 @@
+
+ import sys
+ import os
+-import imp
++import importlib
+ import platform
+ import re
+
+@@ -197,8 +197,8 @@
+ self.name = os.path.basename(suite_path)
+
+ module_name = os.path.join(suite_path, "__init__.py")
+- module = imp.load_source(
+- module_name, os.path.join(suite_path, "__init__.py"))
++ module = importlib.machinery.SourceFileLoader(
++ module_name, os.path.join(suite_path, "__init__.py")).load_module()
+
+ self.keywords = set(module.keywords)
+ self.need_cpp_vars = set(module.need_cpp_vars)
diff -Nru abinit-9.10.4/debian/patches/series abinit-9.10.4/debian/patches/series
--- abinit-9.10.4/debian/patches/series 2023-09-09 09:21:09.000000000 -0700
+++ abinit-9.10.4/debian/patches/series 2024-01-21 14:09:09.000000000 -0800
@@ -4,3 +4,4 @@
testsuite_autopkgtest.patch
tests-python3.patch
build-system-python3.patch
+python3.12.patch
More information about the Debichem-devel
mailing list