Fix Py 3.12 imports (rhbz#2220636)

This commit is contained in:
Michael J Gruber 2023-07-06 15:04:32 +02:00
parent e7bc3c25d5
commit 0f4a84ab4e
2 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,62 @@
From f5ce76603178e5465a744cb4feed4686489bebb9 Mon Sep 17 00:00:00 2001
Message-ID: <f5ce76603178e5465a744cb4feed4686489bebb9.1688648379.git.github@grubix.eu>
From: Michael J Gruber <github@grubix.eu>
Date: Thu, 6 Jul 2023 14:58:03 +0200
Subject: [PATCH] Python 3.12 compatibility: adjust submodule imports
importlib imports behave differently in py 3.11 and py 3.12: py 3.12
requires explicit imports of the submodules.
While fixing this, reduce the imports to the used submodules. Currently,
the base is still imported automatically.
---
lib/dbtexmf/core/dbtex.py | 3 ++-
lib/dbtexmf/dblatex/grubber/plugins.py | 3 ++-
lib/dbtexmf/xslt/xslt.py | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/dbtexmf/core/dbtex.py b/lib/dbtexmf/core/dbtex.py
index adac781..4cf9591 100644
--- a/lib/dbtexmf/core/dbtex.py
+++ b/lib/dbtexmf/core/dbtex.py
@@ -15,7 +15,8 @@ try:
except ImportError:
from urllib.request import pathname2url
import glob
-import importlib
+import importlib.machinery
+import importlib.util
from optparse import OptionParser
from io import open
diff --git a/lib/dbtexmf/dblatex/grubber/plugins.py b/lib/dbtexmf/dblatex/grubber/plugins.py
index 047f2bb..6b4ecb4 100644
--- a/lib/dbtexmf/dblatex/grubber/plugins.py
+++ b/lib/dbtexmf/dblatex/grubber/plugins.py
@@ -4,7 +4,8 @@
Mechanisms to dynamically load extra modules to help the LaTeX compilation.
All the modules must be derived from the TexModule class.
"""
-import importlib
+import importlib.machinery
+import importlib.util
from os.path import *
from dbtexmf.dblatex.grubber.msg import _, msg
diff --git a/lib/dbtexmf/xslt/xslt.py b/lib/dbtexmf/xslt/xslt.py
index 57c99a2..7cc2038 100644
--- a/lib/dbtexmf/xslt/xslt.py
+++ b/lib/dbtexmf/xslt/xslt.py
@@ -2,7 +2,8 @@
# Very simple plugin loader for Xslt classes
#
import os
-import importlib
+import importlib.machinery
+import importlib.util
import glob
import sys
--
2.41.0.411.gd9071d4297

View File

@ -1,6 +1,6 @@
Name: dblatex
Version: 0.3.12
Release: 13%{?dist}
Release: 14%{?dist}
Summary: DocBook to LaTeX/ConTeXt Publishing
BuildArch: noarch
# Most of package is GPLv2+, except:
@ -19,6 +19,8 @@ Patch1: dblatex-0.3.11-which-shutil.patch
Patch2: dblatex-0.3.11-replace-inkscape-by-rsvg.patch
# Patch3 sent upstream: https://sourceforge.net/p/dblatex/patches/12/
Patch3: dblatex-0.3.12-replace-imp-by-importlib.patch
# Patch4 sent upstream: https://sourceforge.net/p/dblatex/patches/13/
Patch4: dblatex-0.3.12-adjust-submodule-imports.patch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
@ -132,6 +134,9 @@ cp -p %{SOURCE1} COPYING-docbook-xsl
%postun -p /usr/bin/texhash
%changelog
* Thu Jul 06 2023 Michael J Gruber <mjg@fedoraproject.org> - 0.3.12-14
- Fix Py 3.12 imports (rhbz#2220636)
* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 0.3.12-13
- Rebuilt for Python 3.12