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: Compiling from source prints «ModuleNotFoundError: No module named 'binascii'»
Type: compile error Stage: resolved
Components: Installation Versions: Python 3.10
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, dilyan.palauzov
Priority: normal Keywords:

Created on 2022-01-30 08:52 by dilyan.palauzov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg412134 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2022-01-30 08:52
I compile python from source:

$ python --version
Python 3.10.1+
$ cat /etc/config.site 
ax_cv_c_float_words_bigendian=no
enable_silent_rules=yes
$ git describe 
v3.10.2-74-ga5451c96a1
$ ./configure --enable-loadable-sqlite-extensions --disable-ipv6 --with-system-expat --with-system-libmpdec --enable-shared
$ make
gcc -c -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal  -I. -I./Include   -fPIC -DPy_BUILD_CORE -o Modules/_math.o Modules/_math.c
LD_LIBRARY_PATH=/git/cpython CC='gcc' LDSHARED='gcc -shared    ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall'    _TCLTK_INCLUDES='-I/usr/local/include' _TCLTK_LIBS='-L/usr/local/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6'         ./python -E ./setup.py  build
Traceback (most recent call last):
  File "/git/cpython/./setup.py", line 50, in <module>
    from distutils.command.install import install
  File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/command/install.py", line 20, in <module>
    from .. import _collections
  File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 16, in <module>
    import setuptools.version
  File "/usr/local/lib/python3.10/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 23, in <module>
    import zipfile
  File "/git/cpython/Lib/zipfile.py", line 6, in <module>
    import binascii
ModuleNotFoundError: No module named 'binascii'
make: *** [Makefile:637: sharedmods] Error 1


When I compiled python 3.10 using python 3.8 one or two months ago, there was no such problem.

Compiling python from source code, shall use the bundled distutils, not the installed one.

My Linux From Scratch system appears not to have module binascii:

$ locate binascii
/usr/local/lib/python3.10/lib-dynload/binascii.cpython-310-x86_64-linux-gnu.so
/usr/local/lib/python3.10/test/__pycache__/test_binascii.cpython-310.opt-1.pyc
/usr/local/lib/python3.10/test/__pycache__/test_binascii.cpython-310.opt-2.pyc
/usr/local/lib/python3.10/test/__pycache__/test_binascii.cpython-310.pyc
/usr/local/lib/python3.10/test/test_binascii.py
/usr/local/lib/python3.8/lib-dynload/binascii.cpython-38-x86_64-linux-gnu.so
/usr/local/lib/python3.8/site-packages/mypy/typeshed/stdlib/@python2/binascii.pyi
/usr/local/lib/python3.8/site-packages/mypy/typeshed/stdlib/binascii.pyi
/usr/local/lib/python3.8/test/__pycache__/test_binascii.cpython-38.opt-1.pyc
/usr/local/lib/python3.8/test/__pycache__/test_binascii.cpython-38.opt-2.pyc
/usr/local/lib/python3.8/test/__pycache__/test_binascii.cpython-38.pyc
/usr/local/lib/python3.8/test/test_binascii.py
/git/cpython/Modules/binascii.c
/git/cpython/Modules/clinic/binascii.c.h
/git/cpython/Lib/test/test_binascii.py
/git/cpython/Doc/library/binascii.rst
msg412138 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-30 11:02
You are affected by setuptools bug https://github.com/pypa/setuptools/issues/3007 . The setuptools issues has a workaround. The next version of setuptools will come with a fix.
msg412142 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2022-01-30 12:45
The problem is, that Python’s install target depends on the system-wide setuptools, if there is system-wide setuptools.  If there is no system-wide installed setuptools, apparently the installation works flawlessly.

The solution is to tweak the source code of Python, not to depend on (system-wide installed) Python code outside of Python’s tarball.
msg412143 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-30 13:10
CPython's build system does not depend on setuptools.

The problem is that setuptools 60.0 introduced a .pth file and _distutils_hack to inject itself into Python import system. Under some circumstances Python's build system is affected by the hack and breaks.
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90737
2022-01-30 13:10:09christian.heimessetmessages: + msg412143
2022-01-30 12:45:33dilyan.palauzovsetmessages: + msg412142
2022-01-30 11:02:51christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg412138

resolution: third party
stage: resolved
2022-01-30 08:52:22dilyan.palauzovcreate