Balena Cloud CLI build failing for ARM V6 but good on V8

Hi,

Slowly working myself through the initial Balena Cloud experience. Currently working with two fleets one for ARM V6 devices (Pi Zero W) and another one for ARM V8 (e.g. PI 4 and CM4 devices).

Have built some basic infrastructure in Python 3.10 and been playing with both fleets in parallel.

So far so good.

Now I am adding a few REST endpoints and other services requireing aiohttp. Very simple and small for now.

All works well locally on an M1 Mac as well as on the ARM V8 fleet. However the builds for AMR V6 started failing the moment I added aiohttp to requirements.txt. Tried to run builds with the -c flag (to skip cache) but no change.

When I remove aiohttp from my pip install list, the build is successful on ARM V6.

Here is the build error:

...
[main]       creating build/temp.linux-armv6l-3.10
[main]       creating build/temp.linux-armv6l-3.10/aiohttp
[main]       gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.10 -c aiohttp/_websocket.c -o build/temp.linux-armv6l-3.10/aiohttp/_websocket.o
[main]       error: command 'gcc' failed: No such file or directory
[main]       ----------------------------------------
[main]     
[main]       ERROR: Failed building wheel for aiohttp
...

Your help would be much appreciated!

Any help would be much appreciated!

Ok found the issue, maybe this can help others:

If there is any python dependency that requires a gcc build step for any particular image - in this case aiohttp for ARM V6 in balenalib/%%BALENA_MACHINE_NAME%%-python:3.10-buster-run

one needs to setup a multistep build and first compile the wheels with a build image:
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3.10-buster-build

For now I am just using the much larger build image as my new base, but enventually I will convert to a multistep build and then copy the built wheels into the much lighter run image.

Multi-stage builds is the recommended approach. It doesn’t look like compiled aiohttprelease is available and so it requires to be built as part fo the build.