From b65785a197cfced467b81171b229ec38d8dca6a1 Mon Sep 17 00:00:00 2001 From: kkz Date: Mon, 13 Dec 2021 13:37:27 +0800 Subject: [PATCH 1/2] modify spec to remove some unnecessary build requires --- python-sphinx.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/python-sphinx.spec b/python-sphinx.spec index e91fcad..26231dd 100644 --- a/python-sphinx.spec +++ b/python-sphinx.spec @@ -29,10 +29,8 @@ BuildRequires: python3-sphinx-theme-alabaster BuildRequires: dos2unix -BuildRequires: python3-test BuildRequires: python3-html5lib BuildRequires: python3-mock -BuildRequires: python3-pytest BuildRequires: python3-snowballstemmer BuildRequires: gettext -- Gitee From bef5cb3771e86f1f1cf458b284239a1d9a12dae1 Mon Sep 17 00:00:00 2001 From: kkz Date: Mon, 13 Dec 2021 15:03:59 +0800 Subject: [PATCH 2/2] modify spec to remove some unnecessary build requires and add patch to support python 3.10 --- python-sphinx.spec | 5 +++- support_python310.patch | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 support_python310.patch diff --git a/python-sphinx.spec b/python-sphinx.spec index 26231dd..bc24056 100644 --- a/python-sphinx.spec +++ b/python-sphinx.spec @@ -3,10 +3,13 @@ Version: 3.5.2 Release: 1 Epoch: 1 Summary: Python documentation generator -License: BSD and MIT +License: BSD and MIT URL: http://sphinx-doc.org/ Source0: https://files.pythonhosted.org/packages/source/S/Sphinx/Sphinx-%{version}.tar.gz Patch1: sphinx-test_theming.diff +Patch2: support_python310.patch + + BuildArch: noarch diff --git a/support_python310.patch b/support_python310.patch new file mode 100644 index 0000000..d003fda --- /dev/null +++ b/support_python310.patch @@ -0,0 +1,60 @@ +From d017fb9dcd9830f02df0d644a99de002cc80dd55 Mon Sep 17 00:00:00 2001 +From: root +Date: Mon, 13 Dec 2021 14:59:42 +0800 +Subject: [PATCH] support_python310 + +--- + CHANGES | 2 ++ + sphinx/util/typing.py | 12 ++++++------ + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/CHANGES b/CHANGES +index 9381744..56c2446 100644 +--- a/CHANGES ++++ b/CHANGES +@@ -1,3 +1,5 @@ ++* #9512: sphinx-build: crashed with the HEAD of Python 3.10 ++ + Release 3.5.2 (released Mar 06, 2021) + ===================================== + +diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py +index db754bb..cc06a3b 100644 +--- a/sphinx/util/typing.py ++++ b/sphinx/util/typing.py +@@ -30,10 +30,10 @@ else: + ref = _ForwardRef(self.arg) + return ref._eval_type(globalns, localns) + +-if sys.version_info > (3, 10): +- from types import Union as types_Union +-else: +- types_Union = None ++try: ++ from types import UnionType # type: ignore # python 3.10 or above ++except ImportError: ++ UnionType = None + + if False: + # For type annotation +@@ -107,7 +107,7 @@ def restify(cls: Optional["Type"]) -> str: + return ':class:`struct.Struct`' + elif inspect.isNewType(cls): + return ':class:`%s`' % cls.__name__ +- elif types_Union and isinstance(cls, types_Union): ++ elif UnionType and isinstance(cls, UnionType): + if len(cls.__args__) > 1 and None in cls.__args__: + args = ' | '.join(restify(a) for a in cls.__args__ if a) + return 'Optional[%s]' % args +@@ -349,7 +349,7 @@ def _stringify_py37(annotation: Any) -> str: + elif hasattr(annotation, '__origin__'): + # instantiated generic provided by a user + qualname = stringify(annotation.__origin__) +- elif types_Union and isinstance(annotation, types_Union): # types.Union (for py3.10+) ++ elif UnionType and isinstance(annotation, UnionType): # types.Union (for py3.10+) + qualname = 'types.Union' + else: + # we weren't able to extract the base type, appending arguments would +-- +2.27.0 + -- Gitee