Author Nils Kattenbeck
Recipients Nils Kattenbeck, bethard, ncoghlan, paul.j3, peter.otten, samuelmarks, tebeka, zertrin
Date 2021-07-23.16:08:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627056492.49.0.849443333274.issue22240@roundup.psfhosted.org>
In-reply-to
Content
I expanded the patch from tebeka to also work with invocations like `python3 -m serial.tools.miniterm` where `miniterm.py` is a file and not a directory with a `__main__.py`. This was able to handle everything I threw at it.

However due to the import of zipfile which itself imports binascii the build of CPython itself fails at the `sharedmods` stage...


```text
 CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' 	_TCLTK_INCLUDES='' _TCLTK_LIBS='' 	./python -E ./setup.py  build
Traceback (most recent call last):
  File "/home/septatrix/Documents/programming/cpython/./setup.py", line 3, in <module>
    import argparse
    ^^^^^^^^^^^^^^^
  File "/home/septatrix/Documents/programming/cpython/Lib/argparse.py", line 93, in <module>
    from zipfile import is_zipfile as _is_zipfile
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/septatrix/Documents/programming/cpython/Lib/zipfile.py", line 6, in <module>
    import binascii
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'binascii'
make: *** [Makefile:639: sharedmods] Error 1
```

I guess this is because binascii is a c module and not yet build at that point in time. Does anyone who knows more about the build system have an idea how to resolve this?

---

Resolving this bug would also allow the removal of several workarounds for this in the stdlib:

* https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/unittest/__main__.py#L4
* https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/json/tool.py#L19
* https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/venv/__init__.py#L426
History
Date User Action Args
2021-07-23 16:08:12Nils Kattenbecksetrecipients: + Nils Kattenbeck, tebeka, ncoghlan, peter.otten, bethard, paul.j3, zertrin, samuelmarks
2021-07-23 16:08:12Nils Kattenbecksetmessageid: <1627056492.49.0.849443333274.issue22240@roundup.psfhosted.org>
2021-07-23 16:08:12Nils Kattenbecklinkissue22240 messages
2021-07-23 16:08:12Nils Kattenbeckcreate