From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-text/dblatex/, app-text/dblatex/files/
Date: Thu, 13 Jun 2024 10:37:19 +0000 (UTC) [thread overview]
Message-ID: <1718275009.35a1ef8369dfc368ed9ca408bcc117ae76a6e3a3.mgorny@gentoo> (raw)
commit: 35a1ef8369dfc368ed9ca408bcc117ae76a6e3a3
Author: Zoltan Puskas <zoltan <AT> sinustrom <DOT> info>
AuthorDate: Mon Jun 10 05:51:42 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 10:36:49 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=35a1ef83
app-text/dblatex: Fix Python issues
Migrate to PEP517 while also adding compatibility for 3.12
Closes: https://bugs.gentoo.org/909897
Closes: https://bugs.gentoo.org/929361
Closes: https://bugs.gentoo.org/922530
Signed-off-by: Zoltan Puskas <zoltan <AT> sinustrom.info>
Closes: https://github.com/gentoo/gentoo/pull/37102
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
app-text/dblatex/dblatex-0.3.12-r3.ebuild | 95 +++++++++++++++++
.../dblatex-0.3.12-adjust-submodule-imports.patch | 62 +++++++++++
.../dblatex-0.3.12-replace-imp-by-importlib.patch | 113 +++++++++++++++++++++
3 files changed, 270 insertions(+)
diff --git a/app-text/dblatex/dblatex-0.3.12-r3.ebuild b/app-text/dblatex/dblatex-0.3.12-r3.ebuild
new file mode 100644
index 000000000000..668691aed385
--- /dev/null
+++ b/app-text/dblatex/dblatex-0.3.12-r3.ebuild
@@ -0,0 +1,95 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit distutils-r1
+
+DESCRIPTION="Transform DocBook using TeX macros"
+HOMEPAGE="https://dblatex.sourceforge.net/"
+SRC_URI="https://downloads.sourceforge.net/project/dblatex/dblatex/${P}/${PN}3-${PV}.tar.bz2"
+S="${WORKDIR}/${PN}3-${PV}"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+IUSE="inkscape test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+ app-text/docbook-xml-dtd:4.5
+ dev-libs/kpathsea
+ dev-libs/libxslt
+ dev-texlive/texlive-fontutils
+ dev-texlive/texlive-latex
+ dev-texlive/texlive-latexextra
+ dev-texlive/texlive-latexrecommended
+ dev-texlive/texlive-mathscience
+ dev-texlive/texlive-pictures
+ dev-texlive/texlive-xetex
+ gnome-base/librsvg
+ media-gfx/imagemagick
+ >=media-gfx/fig2dev-3.2.9-r1
+ inkscape? ( media-gfx/inkscape )
+"
+DEPEND="
+ ${RDEPEND}
+"
+BDEPEND="
+ ${RDEPEND}
+ test? ( ~${CATEGORY}/${P}[${PYTHON_USEDEP}] )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.3.11-path-logging.patch"
+ "${FILESDIR}/${PN}-0.3.11-setup.patch"
+ "${FILESDIR}/${PN}-0.3.11-encode.patch"
+ "${FILESDIR}/${P}-replace-imp-by-importlib.patch"
+ "${FILESDIR}/${P}-adjust-submodule-imports.patch"
+)
+
+python_prepare_all() {
+ # Manual page is precomressed, but we will use our own compression later.
+ gunzip docs/manpage/dblatex.1.gz || die
+ if use inkscape; then
+ # If we use inscape we want to make dblatex compatible with v1.0
+ eapply "${FILESDIR}/${PN}-0.3.11-inkscape-1.0.patch"
+ else
+ # If we don't have inkscape we need to use an alternative SVG converter
+ eapply "${FILESDIR}/${PN}-0.3.11-no-inkscape-dependency.patch"
+ fi
+
+ distutils-r1_python_prepare_all
+}
+
+python_install() {
+ distutils-r1_python_install
+
+ # After migrating to PEP517 setuptool's distutils behaves a bit differently.
+ # Rather than rewriting the entire build setup we follow Debian's path with
+ # a predefined script.
+ python_newscript - dblatex <<-EOF
+ #!${EPREFIX}/usr/bin/python
+ import sys
+ import os
+
+ package_base = r"${EPREFIX}/usr/share/dblatex"
+
+ from dbtexmf.dblatex import dblatex
+ dblatex.main(base=package_base)
+ EOF
+}
+
+python_install_all() {
+ distutils-r1_python_install_all
+
+ # Move package documentation to a folder name containing version number
+ mv "${ED}"/usr/share/doc/${PN} "${ED}"/usr/share/doc/${PF} || die
+}
+
+python_test() {
+ emake -C tests/mathml
+}
diff --git a/app-text/dblatex/files/dblatex-0.3.12-adjust-submodule-imports.patch b/app-text/dblatex/files/dblatex-0.3.12-adjust-submodule-imports.patch
new file mode 100644
index 000000000000..9a09ede9db8e
--- /dev/null
+++ b/app-text/dblatex/files/dblatex-0.3.12-adjust-submodule-imports.patch
@@ -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
+
diff --git a/app-text/dblatex/files/dblatex-0.3.12-replace-imp-by-importlib.patch b/app-text/dblatex/files/dblatex-0.3.12-replace-imp-by-importlib.patch
new file mode 100644
index 000000000000..0531733c7f55
--- /dev/null
+++ b/app-text/dblatex/files/dblatex-0.3.12-replace-imp-by-importlib.patch
@@ -0,0 +1,113 @@
+diff --git a/lib/dbtexmf/core/dbtex.py b/lib/dbtexmf/core/dbtex.py
+index b3ec732..adac781 100644
+--- a/lib/dbtexmf/core/dbtex.py
++++ b/lib/dbtexmf/core/dbtex.py
+@@ -15,7 +15,7 @@ try:
+ except ImportError:
+ from urllib.request import pathname2url
+ import glob
+-import imp
++import importlib
+ from optparse import OptionParser
+ from io import open
+
+@@ -540,15 +540,14 @@ class DbTexCommand:
+
+ def load_plugin(self, pathname):
+ moddir, modname = os.path.split(pathname)
+- try:
+- filemod, path, descr = imp.find_module(modname, [moddir])
+- except ImportError:
+- try:
+- filemod, path, descr = imp.find_module(modname)
+- except ImportError:
+- failed_exit("Error: '%s' module not found" % modname)
+- mod = imp.load_module(modname, filemod, path, descr)
+- filemod.close()
++ spec = importlib.machinery.PathFinder.find_spec(modname, [moddir])
++ if not spec:
++ spec = importlib.machinery.PathFinder.find_spec(modname)
++ if not spec:
++ failed_exit("Error: '%s' module not found" % modname)
++ mod = importlib.util.module_from_spec(spec)
++ spec.loader.exec_module(mod)
++ sys.modules[modname] = mod
+ return mod
+
+ def run_setup(self, options):
+diff --git a/lib/dbtexmf/dblatex/grubber/plugins.py b/lib/dbtexmf/dblatex/grubber/plugins.py
+index 9e333c9..047f2bb 100644
+--- a/lib/dbtexmf/dblatex/grubber/plugins.py
++++ b/lib/dbtexmf/dblatex/grubber/plugins.py
+@@ -4,7 +4,7 @@
+ Mechanisms to dynamically load extra modules to help the LaTeX compilation.
+ All the modules must be derived from the TexModule class.
+ """
+-import imp
++import importlib
+
+ from os.path import *
+ from dbtexmf.dblatex.grubber.msg import _, msg
+@@ -108,17 +108,16 @@ class Plugins (object):
+ """
+ if name in self.modules:
+ return 2
+- try:
+- file, path, descr = imp.find_module(name, [""])
+- except ImportError:
++ spec = importlib.machinery.PathFinder.find_spec(name, [""])
++ if not spec:
+ if not self.path:
+ return 0
+- try:
+- file, path, descr = imp.find_module(name, self.path)
+- except ImportError:
+- return 0
+- module = imp.load_module(name, file, path, descr)
+- file.close()
++ spec = importlib.machinery.PathFinder.find_spec(name, self.path)
++ if not spec:
++ return 0
++ module = importlib.util.module_from_spec(spec)
++ spec.loader.exec_module(module)
++ sys.modules[name] = module
+ self.modules[name] = module
+ return 1
+
+diff --git a/lib/dbtexmf/xslt/xslt.py b/lib/dbtexmf/xslt/xslt.py
+index 0350e30..57c99a2 100644
+--- a/lib/dbtexmf/xslt/xslt.py
++++ b/lib/dbtexmf/xslt/xslt.py
+@@ -2,20 +2,21 @@
+ # Very simple plugin loader for Xslt classes
+ #
+ import os
+-import imp
++import importlib
+ import glob
++import sys
+
+ def load(modname):
+- try:
+- file, path, descr = imp.find_module(modname, [""])
+- except ImportError:
+- try:
+- file, path, descr = imp.find_module(modname,
+- [os.path.dirname(__file__)])
+- except ImportError:
+- raise ValueError("Xslt '%s' not found" % modname)
+- mod = imp.load_module(modname, file, path, descr)
+- file.close()
++ spec = importlib.machinery.PathFinder.find_spec(modname, [""])
++ if not spec:
++ spec = importlib.machinery.PathFinder.find_spec(modname,
++ [os.path.dirname(__file__)])
++ if not spec:
++ raise ValueError("Xslt '%s' not found" % modname)
++
++ mod = importlib.util.module_from_spec(spec)
++ spec.loader.exec_module(mod)
++ sys.modules[modname] = mod
+ o = mod.Xslt()
+ return o
+
next reply other threads:[~2024-06-13 10:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 10:37 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-05 12:19 [gentoo-commits] repo/gentoo:master commit in: app-text/dblatex/, app-text/dblatex/files/ Joonas Niilola
2020-03-03 6:03 Joonas Niilola
2015-11-09 0:27 Amy Winston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1718275009.35a1ef8369dfc368ed9ca408bcc117ae76a6e3a3.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox