Repository: pyinstaller/pyinstaller

Issue:
Installation on Armv6l creates a Linux-32bit-unknown bootloader.
## Description of the issue
When installing on a RPi 1b you get an incorrectly named bootloader created. The directory is called Linux-32bit-unknown and not Linux-32bit-arm.

### Context information (for bug reports)

* Output of `pyinstaller --version`: ```4.8```
* Version of Python: <!-- e.g. 3.7 --> 3.7
* Platform: <!-- e.g GNU/Linux (distribution), Windows (language settings), OS X, FreeBSD --> Raspbian GNU/Linux 10 (buster)* How you installed Python: <!-- e.g. python.org/downloads, conda, brew, pyenv, apt, Windows store -->pip3 install pyinstaller
* Did you also try this on another platform? Does it work there? yes.



  * [x] start with clean installation
  * [x] use the latest development version



Discussion:
> How you installed Python: pip3 install pyinstaller

That's a strange way to install Python :raised_eyebrow: ...

To fix this we'll need to figure out what happens [here](https://github.com/pyinstaller/pyinstaller/blob/develop/bootloader/wscript#L87) on your Pi. Fortunately, (to my surprise) we had the foresight to inject some logging there but unfortunately, pip suppresses it so you won't see it via `pip install`. Can you build the bootloader manually and share the logs?

```bash
git clone git@github.com:pyinstaller/pyinstaller.git
cd pyinstaller
PYINSTALLER_COMPILE_BOOTLOADER=1 python setup.py build_bootloader
```

I get this:

```
root@rpi-1-b:~/pyinstaller# PYINSTALLER_COMPILE_BOOTLOADER=1 python setup.py build_bootloader
  File "setup.py", line 73
    file=sys.stderr
        ^
SyntaxError: invalid syntax
root@rpi-1-b:~/pyinstaller# 

```
Building it manually works:
```
root@rpi-1-b:~/pyinstaller/bootloader# python3 ./waf all
'all' finished successfully (0.015s)
'distclean' finished successfully (0.015s)
Setting top to                           : /root/pyinstaller/bootloader 
Setting out to                           : /root/pyinstaller/bootloader/build 
Python Version                           : 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] 
Checking for 'gcc' (C compiler)          : /usr/bin/gcc 
Checking size of pointer                 : 4 
Platform                                 : Linux-32bit-arm detected based on compiler 
Checking for compiler flags -m32         : no 
Checking for linker flags -m32           : no 
Checking for library dl                  : yes 
Checking for library pthread             : yes 
Checking for library m                   : yes 
Checking for library z                   : yes 
Checking for library cmocka              : not found 
Checking for function unsetenv           : yes 
Checking for function mkdtemp            : yes 
Checking for function dirname            : yes 
Checking for function basename           : yes 
Checking for function strndup            : yes 
Checking for function strnlen            : yes 
Checking for compiler flags -Wl,--as-needed : yes 
Checking for program 'strip'                : /usr/bin/strip 
Checking for program 'strip'                : /usr/bin/strip 
'configure' finished successfully (30.363s)
'make_all' finished successfully (0.299s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/debug'
[ 1/16] Compiling src/pyi_path.c
[ 2/16] Compiling src/pyi_exception_dialog.c
[ 3/16] Compiling src/pyi_apple_events.c
[ 4/16] Compiling src/pyi_win32_utils.c
[ 5/16] Compiling src/pyi_utils.c
[ 6/16] Compiling src/pyi_main.c
[ 7/16] Compiling src/pyi_archive.c
[ 8/16] Compiling src/pyi_splash.c
[ 9/16] Compiling src/pyi_global.c
[10/16] Compiling src/pyi_python.c
[11/16] Compiling src/pyi_splashlib.c
[12/16] Compiling src/pyi_pythonlib.c
[13/16] Compiling src/pyi_launch.c
[14/16] Compiling src/main.c
[15/16] Linking build/debug/run_d
[16/16] Processing build/debug/run_d
Waf: Leaving directory `/root/pyinstaller/bootloader/build/debug'
'build_debug' finished successfully (59.899s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/release'
[ 1/16] Compiling src/pyi_path.c
[ 2/16] Compiling src/pyi_exception_dialog.c
[ 3/16] Compiling src/pyi_apple_events.c
[ 4/16] Compiling src/pyi_win32_utils.c
[ 5/16] Compiling src/pyi_utils.c
[ 6/16] Compiling src/pyi_main.c
[ 7/16] Compiling src/pyi_archive.c
[ 8/16] Compiling src/pyi_splash.c
[ 9/16] Compiling src/pyi_global.c
[10/16] Compiling src/pyi_python.c
[11/16] Compiling src/pyi_splashlib.c
[12/16] Compiling src/pyi_pythonlib.c
[13/16] Compiling src/pyi_launch.c
[14/16] Compiling src/main.c
[15/16] Linking build/release/run
[16/16] Processing build/release/run
Waf: Leaving directory `/root/pyinstaller/bootloader/build/release'
'build_release' finished successfully (56.974s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/debug'
[16/17] Processing build/debug/run_d
+ install /root/pyinstaller/PyInstaller/bootloader/Linux-32bit-arm/run_d (from build/debug/run_d)                                                            
Waf: Leaving directory `/root/pyinstaller/bootloader/build/debug'
'install_debug' finished successfully (1.127s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/release'
+ install /root/pyinstaller/PyInstaller/bootloader/Linux-32bit-arm/run (from build/release/run)                                                              
[17/17] Processing build/release/run
Waf: Leaving directory `/root/pyinstaller/bootloader/build/release'
'install_release' finished successfully (0.659s)
root@rpi-1-b:~/pyinstaller/bootloader#
```
> I get this:
> 
> ```
> root@rpi-1-b:~/pyinstaller# PYINSTALLER_COMPILE_BOOTLOADER=1 python setup.py build_bootloader
>   File "setup.py", line 73
>     file=sys.stderr
>         ^
> SyntaxError: invalid syntax
> root@rpi-1-b:~/pyinstaller# 
> ```

`python` -> `python3`
Sorry phat fingers ;-)

```
root@rpi-1-b:~# cd pyinstaller/
root@rpi-1-b:~/pyinstaller# PYINSTALLER_COMPILE_BOOTLOADER=1 python3 setup.py build_bootloader 2>&1 | tee output.log
running build_bootloader
Setting top to                           : /root/pyinstaller/bootloader 
Setting out to                           : /root/pyinstaller/bootloader/build 
Python Version                           : 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] 
Checking for 'gcc' (C compiler)          : /usr/bin/gcc 
Checking size of pointer                 : 4 
Platform                                 : Linux-32bit-arm detected based on compiler 
Checking for compiler flags -m32         : no 
Checking for linker flags -m32           : no 
Checking for library dl                  : yes 
Checking for library pthread             : yes 
Checking for library m                   : yes 
Checking for library z                   : yes 
Checking for library cmocka              : not found 
Checking for function unsetenv           : yes 
Checking for function mkdtemp            : yes 
Checking for function dirname            : yes 
Checking for function basename           : yes 
Checking for function strndup            : yes 
Checking for function strnlen            : yes 
Checking for compiler flags -Wl,--as-needed : yes 
Checking for program 'strip'                : /usr/bin/strip 
Checking for program 'strip'                : /usr/bin/strip 
'configure' finished successfully (28.518s)
'all' finished successfully (0.004s)
'distclean' finished successfully (0.130s)
Setting top to                           : /root/pyinstaller/bootloader 
Setting out to                           : /root/pyinstaller/bootloader/build 
Python Version                           : 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] 
Checking for 'gcc' (C compiler)          : /usr/bin/gcc 
Checking size of pointer                 : 4 
Platform                                 : Linux-32bit-arm detected based on compiler 
Checking for compiler flags -m32         : no 
Checking for linker flags -m32           : no 
Checking for library dl                  : yes 
Checking for library pthread             : yes 
Checking for library m                   : yes 
Checking for library z                   : yes 
Checking for library cmocka              : not found 
Checking for function unsetenv           : yes 
Checking for function mkdtemp            : yes 
Checking for function dirname            : yes 
Checking for function basename           : yes 
Checking for function strndup            : yes 
Checking for function strnlen            : yes 
Checking for compiler flags -Wl,--as-needed : yes 
Checking for program 'strip'                : /usr/bin/strip 
Checking for program 'strip'                : /usr/bin/strip 
'configure' finished successfully (27.862s)
'make_all' finished successfully (0.270s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/debug'
[ 1/16] Compiling src/pyi_path.c
[ 2/16] Compiling src/pyi_exception_dialog.c
[ 3/16] Compiling src/pyi_apple_events.c
[ 4/16] Compiling src/pyi_win32_utils.c
[ 5/16] Compiling src/pyi_utils.c
[ 6/16] Compiling src/pyi_main.c
[ 7/16] Compiling src/pyi_archive.c
[ 8/16] Compiling src/pyi_splash.c
[ 9/16] Compiling src/pyi_global.c
[10/16] Compiling src/pyi_python.c
[15/16] Linking build/debug/run_d
[16/16] Processing build/debug/run_d
Waf: Leaving directory `/root/pyinstaller/bootloader/build/debug'
'build_debug' finished successfully (59.168s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/release'
[ 1/16] Compiling src/pyi_path.c
[ 2/16] Compiling src/pyi_exception_dialog.c
[ 3/16] Compiling src/pyi_apple_events.c
[ 4/16] Compiling src/pyi_win32_utils.c
[ 5/16] Compiling src/pyi_utils.c
[ 6/16] Compiling src/pyi_main.c
[ 7/16] Compiling src/pyi_archive.c
[ 8/16] Compiling src/pyi_splash.c
[ 9/16] Compiling src/pyi_global.c
[10/16] Compiling src/pyi_python.c
[11/16] Compiling src/pyi_splashlib.c
[12/16] Compiling src/pyi_pythonlib.c
[13/16] Compiling src/pyi_launch.c
[14/16] Compiling src/main.c
[15/16] Linking build/release/run
[16/16] Processing build/release/run
Waf: Leaving directory `/root/pyinstaller/bootloader/build/release'
'build_release' finished successfully (57.765s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/debug'
[16/17] Processing build/debug/run_d
+ install /root/pyinstaller/PyInstaller/bootloader/Linux-32bit-arm/run_d (from build/debug/run_d)                                                            
Waf: Leaving directory `/root/pyinstaller/bootloader/build/debug'
'install_debug' finished successfully (0.888s)
Waf: Entering directory `/root/pyinstaller/bootloader/build/release'
+ install /root/pyinstaller/PyInstaller/bootloader/Linux-32bit-arm/run (from build/release/run)                                                              
[17/17] Processing build/release/run
Waf: Leaving directory `/root/pyinstaller/bootloader/build/release'
'install_release' finished successfully (1.207s)
No precompiled bootloader found or compile forced. Trying to compile the bootloader for you ...                                                              
root@rpi-1-b:~/pyinstaller#
```
Hmm, well both those logs show:
```
Platform                                 : Linux-32bit-arm detected based on compiler 
```
and
```
+ install /root/pyinstaller/PyInstaller/bootloader/Linux-32bit-arm/run (from build/release/run)                                                              
```
which show it correctly detecting arm and installing the bootloaders in the designated `Linux-32bit-arm` directory. Can you confirm that just `pip install pyinstaller` really is downloading and installing from an sdist from PyPI and not a precompiled wheel from piwheels.org or some other Pi-only repository? e.g. Use:
```
pip install --no-cache-dir --force-reinstall -v pyinstaller
```
I've tried this on a fresh virtual environment and it still doesn't work.
```
root@rpi-1-b:~# python3 -m venv venv
root@rpi-1-b:~# source venv/bin/activate
(venv) root@rpi-1-b:~# pip install --no-cache-dir --force-reinstall -v pyinstaller
(venv) root@rpi-1-b:~# find venv/lib/python3.7/site-packages/PyInstaller/bootloader -type f
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-64bit/runw_d.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-64bit/run_d.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-64bit/runw.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-64bit/run.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-console.ico
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-console.svg
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-windowed.svg
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/github_logo.png
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-windowed.icns
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-console.icns
venv/lib/python3.7/site-packages/PyInstaller/bootloader/images/icon-windowed.ico
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-unknown/run
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-unknown/run_d
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Darwin-64bit/run
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Darwin-64bit/runw_d
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Darwin-64bit/runw
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Darwin-64bit/run_d
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-32bit/runw_d.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-32bit/run_d.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-32bit/runw.exe
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Windows-32bit/run.exe
```
Yeah, but the problem is very likely that your Pi is getting [pyinstaller wheel](https://www.piwheels.org/project/pyinstaller/) from [piwheels](https://www.piwheels.org/). And that one does, indeed, have bootloader in `Linux-32bit-unknown`... So you'll need to install from sdist.

Somewhat off-topic: if piwheels is trying to target both armv6l and armv7l, should it not be providing two distinct arch-specific wheels? Or is the bootloader in its pyinstaller wheel targeting armv6l and thus works on both?
I think you are right there, the no-binary option works as expected:

```
root@rpi-1-b:~# python3 -m venv venv --symlinks
root@rpi-1-b:~# source venv/bin/activate
(venv) root@rpi-1-b:~# pip3 install --no-binary pyinstaller pyinstaller
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyinstaller
  Downloading https://files.pythonhosted.org/packages/7f/6b/688fceb8f1fafeb028de72ad47c5b1377be9f74a75801802f1463e451b22/pyinstaller-4.8.tar.gz (2.8MB)
    100% |████████████████████████████████| 2.8MB 18kB/s
  Installing build dependencies ... done
Requirement already satisfied: setuptools in ./venv/lib/python3.7/site-packages (from pyinstaller) (40.8.0)
Collecting altgraph (from pyinstaller)
  Using cached https://files.pythonhosted.org/packages/84/3f/1a5c9bef54cac9bf41edd6f4aaf61cd52ed578e10ccc607e0278012cb4a5/altgraph-0.17.2-py2.py3-none-any.whl
Collecting pyinstaller-hooks-contrib>=2020.6 (from pyinstaller)
  Using cached https://files.pythonhosted.org/packages/a5/51/aca8508043b9564620bdd96adbc824b8d84537afcfb92ff806ea119ee176/pyinstaller_hooks_contrib-2022.0-py2.py3-none-any.whl
Collecting importlib-metadata (from pyinstaller)
  Using cached https://files.pythonhosted.org/packages/58/fd/f82049e9b21773188a72bd1bc53530b900392808f8b823e4c778e7c035f0/importlib_metadata-4.10.1-py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata->pyinstaller)
  Using cached https://files.pythonhosted.org/packages/52/c5/df7953fe6065185af5956265e3b16f13c2826c2b1ba23d43154f3af453bc/zipp-3.7.0-py3-none-any.whl
Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata->pyinstaller)
  Using cached https://files.pythonhosted.org/packages/05/e4/baf0031e39cf545f0c9edd5b1a2ea12609b7fcba2d58e118b11753d68cf0/typing_extensions-4.0.1-py3-none-any.whl
Skipping bdist_wheel for pyinstaller, due to binaries being disabled for it.
Installing collected packages: altgraph, pyinstaller-hooks-contrib, zipp, typing-extensions, importlib-metadata, pyinstaller
  Running setup.py install for pyinstaller ... done
Successfully installed altgraph-0.17.2 importlib-metadata-4.10.1 pyinstaller-4.8 pyinstaller-hooks-contrib-2022.0 typing-extensions-4.0.1 zipp-3.7.0
(venv) root@rpi-1-b:~# !find
find venv/lib/python3.7/site-packages/PyInstaller/bootloader -type f
[ ... ]
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-arm/run
venv/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-arm/run_d
```
> Somewhat off-topic: if piwheels is trying to target both armv6l and armv7l, should it not be providing two distinct arch-specific wheels? Or is the bootloader in its pyinstaller wheel targeting armv6l and thus works on both?

piwheels maintainer here. The Raspberry Pi OS runs in 32-bit userland so that the SD card image works on all Pi models, so when you build an armv7 wheel on a Pi 2/3/4 it's really just armv6 instructions, so we provide the same file for armv6 and armv7. That generally works. If you want to explore whether there might be an issue, please create an issue via the link at the bottom of https://www.piwheels.org/project/pyinstaller/ :+1: 
@bennuttall Thanks for explanation! 

While you're here, do you perhaps have access to build logs for the piwheels pyinstaller wheels? It might help us figure out why our build script failed to identify the arm as target architecture.
Here it is: https://paste.debian.net/1228356/

Having looked at it, I am concerned that this might be an edge case. Recently we had an [issue](https://github.com/piwheels/packages/issues/276) with our OS image including armv7 versions of gcc etc. We rebuilt all the platform wheels, but assumed the pure Python wheels (tagged "none") were ok. From the log I see there's C code being compiled.

How come there's compiled C code but it produces a pure Python wheel? I see your wheels on PyPI have platform tags but always "none" as the ABI tag.

I'm going to rebuild the latest version. I'll add the build log for that when it's done.

New build: https://paste.debian.net/1228357/
> How come there's compiled C code but it produces a pure Python wheel? I see your wheels on PyPI have platform tags but always "none" as the ABI tag.

It's not a pure Python wheel - it contains C code but it's just not linked against `libpython.so` or contains `#include "Python.h"` so wheels are platform dependent but Python version independent. Setuptools has no support for this case and we also have an unfortunate tendency to cross compile so the setting of the wheel tags is somewhat hacked on by our `setup.py`. What's probably throwing you is that we left the default wheel command alone so that:
```
python setup.py bdist_wheel
```
creates a wheel with no platform tag making it look platform independent.
> New build: https://paste.debian.net/1228357/

The new build looks correct, so it was probably indeed the issue you referenced earlier (where the target architecture was determined to be `thumb` instead of `arm`).
Ok glad it's sorted now. Thanks
The updated [PyInstaller 4.8 wheels on piwheels](https://www.piwheels.org/project/pyinstaller/) seem to contain `Linux-32bit-arm` bootloader now, so I'm closing this issue. Thanks to @bennuttall for taking care of the problem!
I think there is a problem with PyInstaller 4.9. For some reason, it does not include the bootloader for `Linux-32bit-arm`. I installed it with `pip install`. I'm using python 3.7.12 with this [docker container](https://github.com/docker-library/python/blob/1b6bc0cc0b1e627965feff9c838cf551d68dab28/3.7/buster/Dockerfile)
Ughh, we're in danger of having exactly the same conversation as above. Check the output of `pip install --no-cache-dir --force-reinstall pyinstaller` to see where's pip pulling PyInstaller from? It'll either be the sdist from PyPI and something's going wrong at compile time, the wrong wheel from PyPI (in which case your pip/Python environment is botched) or a wheel from piwheels.
What bootloader(s) do you get when you do a `pip install`? And what is the output of `uname -m` in your container?
I've just installed 4.9 on a clean Pi, and it downloaded from:
```
https://www.piwheels.org/simple/pyinstaller/pyinstaller-4.9-py3-none-any.whl
```
and I get Linux-32bit-arm bootloader installed.
```
pip install --no-cache-dir --force-reinstall pyinstaller
Collecting pyinstaller
  Downloading pyinstaller-4.9-py3-none-manylinux2014_x86_64.whl (1.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 21.6 MB/s eta 0:00:00
Collecting importlib-metadata
  Downloading importlib_metadata-4.11.0-py3-none-any.whl (17 kB)
Collecting altgraph
  Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Collecting setuptools
  Downloading setuptools-60.8.2-py3-none-any.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 53.5 MB/s eta 0:00:00
Collecting pyinstaller-hooks-contrib>=2020.6
  Downloading pyinstaller_hooks_contrib-2022.1-py2.py3-none-any.whl (223 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 223.7/223.7 KB 244.0 MB/s eta 0:00:00
Collecting zipp>=0.5
  Downloading zipp-3.7.0-py3-none-any.whl (5.3 kB)
Collecting typing-extensions>=3.6.4
  Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Installing collected packages: altgraph, zipp, typing-extensions, setuptools, pyinstaller-hooks-contrib, importlib-metadata, pyinstaller
  Attempting uninstall: setuptools
    Found existing installation: setuptools 60.8.2
    Uninstalling setuptools-60.8.2:
      Successfully uninstalled setuptools-60.8.2
Successfully installed altgraph-0.17.2 importlib-metadata-4.11.0 pyinstaller-4.9 pyinstaller-hooks-contrib-2022.1 setuptools-60.8.2 typing-extensions-4.0.1 zipp-3.7.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
```
> pyinstaller-4.9-py3-none-manylinux2014_x86_64.whl

@umbynos you seem to be on x86_64 - why are you expecting to get arm bootloader?
That was just a test. The problem seems to be a different one. 
Basically, the architecture is not recognized correctly... But I don't know if it's a pyinstaller or a docker image issue.
In the `arm32v5/python:3.7-buster` docker container, if I run `uname -m` I get `armv7l` 🤷‍♂️ and:
```
ls /usr/local/lib/python3.7/site-packages/PyInstaller/bootloader/
Darwin-64bit
Linux-32bit-arm
Windows-32bit
Windows-64bit
images
```

While in the `arm32v7/python:3.7-buster` docker container, if I run `uname -m` I get `armv7l` too. But:
```
ls /usr/local/lib/python3.7/site-packages/PyInstaller/bootloader/
Darwin-64bit
Linux-32bit-unknown
Windows-32bit
Windows-64bit
images
```

> In the `arm32v5/python:3.7-buster` docker container, if I run `uname -m` I get `armv7l` man_shrugging and:

> While in the `arm32v5/python:3.7-buster` docker container, if I run `uname -m` I get `armv7l` too. But:

Ah, you probably meant `arm32v7/python:3.7-buster` - I can confirm that while `arm32v5/python:3.7-buster` ends up with `Linux-32bit-arm` bootloader being built, in  `arm32v7/python:3.7-buster` it is `Linux-32bit-unknown`.
Hmmm, this looks like the same issue as with the faulty piwheels build - `ctx.env.DEST_CPU` is reported as `thumb` which we need to map to `arm`.

`waf` has [mappings](https://gitlab.com/ita1024/waf/-/blob/master/waflib/Tools/c_config.py#L51) for both `__arm__` and `__thumb__`, and (if I recall correctly) the compiler reports both. 

But in our case, we should [map both to arm](https://sourceforge.net/p/predef/wiki/Architectures/).
> Ah, you probably meant arm32v7/python:3.7-buster

Thanks! fixed the comment

Regarding the architecture being wrongly reported by `uname -m`, I also opened as issue [here](https://github.com/docker-library/python/issues/698)
PS I don't know if this can help but it works just fine with version 4.2 of pyinstaller

Resolving patch:
diff --git a/PyInstaller/_shared_with_waf.py b/PyInstaller/_shared_with_waf.py
--- a/PyInstaller/_shared_with_waf.py
+++ b/PyInstaller/_shared_with_waf.py
@@ -57,6 +57,10 @@ def _pyi_machine(machine, system):
     if machine.startswith(("arm", "aarch")):
         # ARM has a huge number of similar and aliased sub-versions, such as armv5, armv6l armv8h, aarch64.
         return "arm"
+    if machine in ("thumb"):
+        # Reported by waf/gcc when Thumb instruction set is enabled on 32-bit ARM. The platform.machine() returns "arm"
+        # regardless of the instruction set.
+        return "arm"
     if machine in ("x86_64", "x64", "x86"):
         return "intel"
     if re.fullmatch("i[1-6]86", machine):


Test patch: