Bug 257770

Summary: textproc/py-sphinx: Add upstream patch to fix runtime error with Python 3.10
Product: Ports & Packages Reporter: Yasuhiro Kimura <yasu>
Component: Individual Port(s)Assignee: Danilo G. Baio <dbaio>
Status: Closed FIXED    
Severity: Affects Only Me CC: 2khramtsov, dbaio, jbeich, rhurlin
Priority: --- Flags: dbaio: maintainer-feedback+
dbaio: merge-quarterly-
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257116
Bug Depends on:    
Bug Blocks: 257694, 257695    
Attachments:
Description Flags
Patch file none

Description Yasuhiro Kimura freebsd_committer freebsd_triage 2021-08-11 15:58:17 UTC
Created attachment 227115 [details]
Patch file

While testing lang/python310, I found runtime error such as following
happens with textproc/py-sphinx if 3.10 is default version of Python.

----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/bin/sphinx-build", line 33, in <module>
    sys.exit(load_entry_point('Sphinx==3.5.2', 'console_scripts', 'sphinx-build')())
  File "/usr/local/bin/sphinx-build", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.10/importlib/metadata/__init__.py", line 162, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.10/site-packages/sphinx/cmd/build.py", line 25, in <module>
    from sphinx.application import Sphinx
  File "/usr/local/lib/python3.10/site-packages/sphinx/application.py", line 32, in <module>
    from sphinx.config import Config
  File "/usr/local/lib/python3.10/site-packages/sphinx/config.py", line 23, in <module>
    from sphinx.util import logging
  File "/usr/local/lib/python3.10/site-packages/sphinx/util/__init__.py", line 35, in <module>
    from sphinx.util import smartypants  # noqa
  File "/usr/local/lib/python3.10/site-packages/sphinx/util/smartypants.py", line 33, in <module>
    from sphinx.util.docutils import __version_info__ as docutils_version
  File "/usr/local/lib/python3.10/site-packages/sphinx/util/docutils.py", line 31, in <module>
    from sphinx.util.typing import RoleFunction
  File "/usr/local/lib/python3.10/site-packages/sphinx/util/typing.py", line 34, in <module>
    from types import Union as types_Union
ImportError: cannot import name 'Union' from 'types' (/usr/local/lib/python3.10/types.py)
----------------------------------------------------------------------

So add upstream patch to fix the problem.

References:
https://github.com/sphinx-doc/sphinx/issues/9512
https://github.com/sphinx-doc/sphinx/pull/9513
https://github.com/sphinx-doc/sphinx/commit/36e06d67c9e4ef6d3d0881aac76066b5c1982ccd
Comment 1 Ghost 2021-09-02 18:33:02 UTC
Also works fine here.
Comment 2 Danilo G. Baio freebsd_committer freebsd_triage 2021-09-02 22:42:09 UTC
Thanks for the patch.

I was hoping to upgrade Sphinx soon, but it will take some time.

We need to confirm if it passes QA and also  check if a few ports that rely on it is building fine.

Then we can submit it.

And maybe we don't need to increase PORTREVISION here and avoid consumers rebuild just for that.
Comment 3 Danilo G. Baio freebsd_committer freebsd_triage 2021-09-19 19:11:23 UTC
Sorry about the delay.

I've started some build tests on ports that rely on Sphinx (a mini exp-run).

If it's all fine, I'll push this in a day or two.
Comment 4 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-09-20 04:10:50 UTC
(In reply to Danilo G. Baio from comment #2)

Would you please revert ports 913219385dfd after my patch is committed?

----------------------------------------------------------------------
commit 913219385dfd
Author: Dmitry Marakasov <amdmi3@FreeBSD.org>
Date:   Sat Aug 21 01:11:31 2021 +0300

    devel/cmake: fix build with python 3.10 as default
    
    Approved by:    portmgt blanket
----------------------------------------------------------------------

As I reported as bug #257694 build of devel/cmake fails if default version of Python is 3.10, and it is because of runtime error of textproc/py-sphinx. ports 913219385dfd works around it by limiting the range of Python to 3.6-3.9. But my patch fixes the error. So after it is committed there is no reason to limit the range of Python any more.
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-09-21 23:46:46 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7583c6f81dcf0b411f932f2384d64efbe83eaf9c

commit 7583c6f81dcf0b411f932f2384d64efbe83eaf9c
Author:     Yasuhiro Kimura <yasu@utahime.org>
AuthorDate: 2021-09-21 23:36:42 +0000
Commit:     Danilo G. Baio <dbaio@FreeBSD.org>
CommitDate: 2021-09-21 23:40:15 +0000

    textproc/py-sphinx: Add upstream patch to fix runtime error with Python 3.10

    PR:             257770
    Approved by:    dbaio (python, maintainer)

 .../files/patch-sphinx_util_typing.py (new)        | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)
Comment 6 Danilo G. Baio freebsd_committer freebsd_triage 2021-09-22 01:42:11 UTC
Committed, thanks!
Follow with cmake change on bug 257694