From 76b2628c856a693fc5934ce74faaa0b75f670f42aa12ae8d0a988358739b42bf Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 24 Jan 2023 06:53:46 +0000 Subject: [PATCH 1/2] - Refactor pygments-2.14.patch to not use distutils. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-docutils?expand=0&rev=81 --- pygments-2.14.patch | 4 ++-- python-docutils.changes | 5 +++++ python-docutils.spec | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pygments-2.14.patch b/pygments-2.14.patch index 551304e..f6be9ed 100644 --- a/pygments-2.14.patch +++ b/pygments-2.14.patch @@ -656,11 +656,11 @@ Index: docutils-0.19/docutils/utils/code_analyzer.py from docutils import ApplicationError try: import pygments -+ from distutils.version import LooseVersion ++ from packaging.version import Version from pygments.lexers import get_lexer_by_name from pygments.formatters.html import _get_ttype_class with_pygments = True -+ pygments_version = LooseVersion(pygments.__version__) ++ pygments_version = Version(pygments.__version__) except ImportError: with_pygments = False + pygments_version = '0' diff --git a/python-docutils.changes b/python-docutils.changes index 6f35b3f..0dca8da 100644 --- a/python-docutils.changes +++ b/python-docutils.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Jan 24 06:53:16 UTC 2023 - Steve Kowalik + +- Refactor pygments-2.14.patch to not use distutils. + ------------------------------------------------------------------- Tue Jan 10 15:42:55 UTC 2023 - Daniel Garcia diff --git a/python-docutils.spec b/python-docutils.spec index 83266b9..9a4fe39 100644 --- a/python-docutils.spec +++ b/python-docutils.spec @@ -45,11 +45,13 @@ Requires(post): update-alternatives Requires(postun):update-alternatives Recommends: python-Pillow Recommends: python-Pygments +Requires: python-packaging Recommends: python-roman BuildArch: noarch %if %{with test} BuildRequires: %{python_module Pillow} BuildRequires: %{python_module Pygments} +BuildRequires: %{python_module packaging} BuildRequires: %{python_module roman} %endif %if "%{python_flavor}" == "python3" || "%{?python_provides}" == "python3" From 5b9782913a5f6b668d85fc89f0781ee631118b8a76f20243fb94c84cc193936c Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 24 Jan 2023 07:15:26 +0000 Subject: [PATCH 2/2] Fix the patch harder. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-docutils?expand=0&rev=82 --- pygments-2.14.patch | 27 +++++++++++++++++---------- python-docutils.changes | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pygments-2.14.patch b/pygments-2.14.patch index f6be9ed..670ad18 100644 --- a/pygments-2.14.patch +++ b/pygments-2.14.patch @@ -2,9 +2,11 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_code.py =================================================================== --- docutils-0.19.orig/test/test_parsers/test_rst/test_directives/test_code.py +++ docutils-0.19/test/test_parsers/test_rst/test_directives/test_code.py -@@ -11,13 +11,18 @@ Test the 'code' directive in parsers/rst +@@ -10,14 +10,20 @@ Test the 'code' directive in parsers/rst + if __name__ == '__main__': import __init__ # noqa: F401 ++from packaging.version import Version from test_parsers import DocutilsTestSupport -from docutils.utils.code_analyzer import with_pygments +from docutils.utils.code_analyzer import with_pygments, pygments_version @@ -15,14 +17,14 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_code.py if not with_pygments: del(totest['code-parsing']) + del(totest['code-parsing-2-14']) -+ elif pygments_version >= '2.14.0': ++ elif pygments_version >= Version('2.14.0'): + del(totest['code-parsing']) + else: + del(totest['code-parsing-2-14']) s.generateTests(totest) return s -@@ -170,6 +175,165 @@ totest['code-parsing'] = [ +@@ -170,6 +176,165 @@ totest['code-parsing'] = [ \n\ print @@ -192,9 +194,11 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_code_long.p =================================================================== --- docutils-0.19.orig/test/test_parsers/test_rst/test_directives/test_code_long.py +++ docutils-0.19/test/test_parsers/test_rst/test_directives/test_code_long.py -@@ -11,14 +11,20 @@ Test the 'code' directive in body.py wit +@@ -10,15 +10,22 @@ Test the 'code' directive in body.py wit + if __name__ == '__main__': import __init__ # noqa: F401 ++from packaging.version import Version from test_parsers import DocutilsTestSupport -from docutils.utils.code_analyzer import with_pygments +from docutils.utils.code_analyzer import with_pygments, pygments_version @@ -204,7 +208,7 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_code_long.p settings = {'syntax_highlight': 'long'} s = DocutilsTestSupport.ParserTestSuite(suite_settings=settings) if with_pygments: -+ if pygments_version >= '2.14.0': ++ if pygments_version >= Version('2.14.0'): + del(totest['code-parsing-long']) + else: + del(totest['code-parsing-long-2-14']) @@ -214,7 +218,7 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_code_long.p return s -@@ -73,6 +79,94 @@ totest['code-parsing-long'] = [ +@@ -73,6 +80,94 @@ totest['code-parsing-long'] = [ \n\ print @@ -313,8 +317,11 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_include.py =================================================================== --- docutils-0.19.orig/test/test_parsers/test_rst/test_directives/test_include.py +++ docutils-0.19/test/test_parsers/test_rst/test_directives/test_include.py -@@ -12,7 +12,7 @@ if __name__ == '__main__': +@@ -10,9 +10,10 @@ Tests for misc.py "include" directive. + import os.path + if __name__ == '__main__': import __init__ # noqa: F401 ++from packaging.version import Version from test_parsers import DocutilsTestSupport from docutils import parsers -from docutils.utils.code_analyzer import with_pygments @@ -322,19 +329,19 @@ Index: docutils-0.19/test/test_parsers/test_rst/test_directives/test_include.py # optional 3rd-party markdown parser md_parser_name = 'recommonmark' -@@ -27,6 +27,11 @@ def suite(): +@@ -27,6 +28,11 @@ def suite(): # eventually skip optional parts: if not with_pygments: del(totest['include-code']) + del(totest['include-code-2-14']) -+ elif pygments_version >= '2.14.0': ++ elif pygments_version >= Version('2.14.0'): + del(totest['include-code']) + else: + del(totest['include-code-2-14']) if not md_parser_class: del(totest['include-markdown']) s.generateTests(totest) -@@ -1191,6 +1196,313 @@ Including includes/include14.txt +@@ -1191,6 +1197,313 @@ Including includes/include14.txt .. \n\ diff --git a/python-docutils.changes b/python-docutils.changes index 0dca8da..323ca15 100644 --- a/python-docutils.changes +++ b/python-docutils.changes @@ -1,5 +1,5 @@ ------------------------------------------------------------------- -Tue Jan 24 06:53:16 UTC 2023 - Steve Kowalik +Tue Jan 24 07:15:02 UTC 2023 - Steve Kowalik - Refactor pygments-2.14.patch to not use distutils.