This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: setuptools' _distutils_hack breaks Python build
Type: compile error Stage: resolved
Components: Build Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, kloczek
Priority: normal Keywords:

Created on 2022-01-16 08:14 by kloczek, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg410680 - (view) Author: Tomasz Kloczko (kloczek) Date: 2022-01-16 08:14
Looks like it is some 3.8.12 build issue.

/usr/bin/gcc -c -fPIC  -DDYNAMIC_ANNOTATIONS_ENABLED=1  -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS  -fstack-protector-strong  -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -Og -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -fno-semantic-interposition -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -Og -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include   -fPIC -DPy_BUILD_CORE -o Modules/_math.o ../Modules/_math.c
LD_LIBRARY_PATH=/home/tkloczko/rpmbuild/BUILD/Python-3.8.12/build-debug CC='/usr/bin/gcc' LDSHARED='/usr/bin/gcc -shared -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g ' OPT='-DDYNAMIC_ANNOTATIONS_ENABLED=1  -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS  -fstack-protector-strong  -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -D_GNU_SOURCE -fPIC -fwrapv'         _TCLTK_INCLUDES='' _TCLTK_LIBS=''       ./python -E ../setup.py  build
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/Python-3.8.12/Lib/subprocess.py", line 64, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../setup.py", line 14, in <module>
    from distutils import log
  File "/usr/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 92, in create_module
    return importlib.import_module('setuptools._distutils')
  File "/home/tkloczko/rpmbuild/BUILD/Python-3.8.12/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.8/site-packages/setuptools/__init__.py", line 8, in <module>
    import _distutils_hack.override  # noqa: F401
  File "/usr/lib/python3.8/site-packages/_distutils_hack/override.py", line 1, in <module>
    __import__('_distutils_hack').do_override()
  File "/usr/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 73, in do_override
    ensure_local_distutils()
  File "/usr/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 60, in ensure_local_distutils
    core = importlib.import_module('distutils.core')
  File "/home/tkloczko/rpmbuild/BUILD/Python-3.8.12/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 17, in <module>
    from distutils.dist import Distribution
  File "/usr/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 19, in <module>
    from distutils.util import check_environ, strtobool, rfc822_escape
  File "/usr/lib/python3.8/site-packages/setuptools/_distutils/util.py", line 14, in <module>
    from distutils.spawn import spawn
  File "/usr/lib/python3.8/site-packages/setuptools/_distutils/spawn.py", line 11, in <module>
    import subprocess
  File "/home/tkloczko/rpmbuild/BUILD/Python-3.8.12/Lib/subprocess.py", line 69, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
make: *** [Makefile:617: sharedmods] Error 1

In the same build env latest 3.9 builds correctly.
msg410690 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-16 09:55
The problem is caused by setuptools 60.x's _distutils_hack. Please report the issue to setuptools or use SETUPTOOLS_USE_DISTUTILS env var to work around the issue.
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90552
2022-01-16 09:59:26christian.heimessettype: compile error
title: 3.8.12: build fails because during handling of the exception, another exception occurred -> setuptools' _distutils_hack breaks Python build
2022-01-16 09:55:30christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg410690

resolution: third party
stage: resolved
2022-01-16 08:15:47kloczeksettitle: 3.8.12: build fails because during handling of the above exception, another exception occurred -> 3.8.12: build fails because during handling of the exception, another exception occurred
2022-01-16 08:14:46kloczekcreate