Bug 257694 - devel/cmake: Fails to build with Python 3.10: ImportError: cannot import name 'Union' from 'types'
Summary: devel/cmake: Fails to build with Python 3.10: ImportError: cannot import name...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Danilo G. Baio
Depends on: 257770
  Show dependency treegraph
Reported: 2021-08-08 23:09 UTC by Yasuhiro Kimura
Modified: 2021-09-23 00:47 UTC (History)
3 users (show)

See Also:
koobs: maintainer-feedback+


Note You need to log in before you can comment on or make changes to this bug.
Description Yasuhiro Kimura freebsd_committer 2021-08-08 23:09:45 UTC
While testing lang/python310 I found build of devel/cmake fails with lang/python310 as default Python.

[ 99%] Linking CXX executable ../../bin/ccmake
[ 99%] Built target ccmake
[100%] sphinx-build man: see Utilities/Sphinx/build-man.log
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)
*** Error code 1


Full build log: https://www.utahime.org/FreeBSD/poudriere/data/logs/bulk/130amd64-default-python310/2021-08-09_07h37m30s/logs/cmake-3.21.0.log

Cc-ing to both kde@ and python@ as I'm not sure what is the source of the error.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-08-09 00:57:11 UTC
If cmake doesn't currently intend, claim or hasnt otherwise been confirmed (tested) to support Python 3.10, it's USES=python <version-spec> should be corrected (bug) to only declare those versions it does support.

Upstream references and CI examples/configs would be handy to validate those details
Comment 2 Yasuhiro Kimura freebsd_committer 2021-08-11 16:04:54 UTC
According to the investigation the source of the problem is that runtime error happens with textproc/py-sphinx if 3.10 is the default version of Python. I submitted the patch to fix it as bug #257770.
Comment 3 Adriaan de Groot freebsd_committer 2021-09-22 09:36:50 UTC
Closing this as the underlying problem -- Python 3.10 source incompatibility -- is now fixed in Sphinx. This only affected devel/cmake because the CMake documentation is processed by Sphinx.

Thank you Yasuhiro Kimura for fixing it in the other PR.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2021-09-23 00:47:50 UTC
^Triage: Assign to committer that resolved