aws / aws/aws-lambda-base-images
Missing freetype-devel and gcc when upgrading from Python 3.10 image to Python 3.12 image
- Dominant language
- No language data
- Stars
- 777
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
### Description:
Python 3.12 images are missing packages that were available for Python 3.10 in Amazon Linux 2 before the migration to Amazon Linux 20023.
### Steps to reproduce:
#### ✅ Working Condition
Try the below Docker file to see the previously working condition with the Python 3.10 image.
```Dockerfile
# any of the below architectures work
# FROM public.ecr.aws/lambda/python:3.10.2025.01.15.17-arm64
FROM public.ecr.aws/lambda/python:3.10.2025.01.15.17-x86_64
RUN pip install -U pip && pip install reportlab==3.6.13
ENTRYPOINT ["python", "-c", \
"from reportlab.pdfgen import canvas; \
c = canvas.Canvas('test.pdf'); \
c.drawString(100,100,'Hello World'); c.save(); \
print('PDF generated as test.pdf')"]
```
Run on your terminal:
```bash
docker build -t test . && docker run --rm test
```
This will output:
```bash
PDF generated as test.pdf
```
---
#### ❌ Broken Condition
Try the above Dockerfile with one of the latest Python 3.12 images, then rebuild and rerun:
```Docker
FROM public.ecr.aws/lambda/python:3.12.2025.01.24.11-x86_64
```
or
```Docker
FROM public.ecr.aws/lambda/python:3.12.2025.01.24.11-arm64
```
This will output the two errors (on separate runs when I added each additional package independently):
```
#5 2.614 Collecting reportlab==3.6.13
#5 2.669 Downloading reportlab-3.6.13.tar.gz (4.0 MB)
#5 2.820 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.0/4.0 MB 32.9 MB/s eta 0:00:00
#5 3.032 Installing build dependencies: started
#5 4.272 Installing build dependencies: finished with status 'done'
#5 4.274 Getting requirements to build wheel: started
#5 4.407 Getting requirements to build wheel: finished with status 'error'
#5 4.411 error: subprocess-exited-with-error
#5 4.411
#5 4.411 × Getting requirements to build wheel did not run successfully.
#5 4.411 │ exit code: 1
#5 4.411 ╰─> [10 lines of output]
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: ================================================
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: Attempting build of _rl_accel
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: extensions from 'src/rl_addons/rl_accel'
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: ================================================
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: ===================================================
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: Attempting build of _renderPM
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: extensions from 'src/rl_addons/renderPM'
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: ===================================================
#5 4.411 ##### setup-python-3.12.7-linux-x86_64: will use package libart 2.3.21
#5 4.411 !!!!! cannot find ft2build.h
#5 4.411 [end of output]
```
or
```bash
#6 11.37 building 'reportlab.lib._rl_accel' extension
#6 11.37 creating build/temp.linux-x86_64-cpython-312/src/rl_addons/rl_accel
#6 11.37 gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/var/lang/include/python3.12 -c src/rl_addons/rl_accel/_rl_accel.c -o build/temp.linux-x86_64-cpython-312/src/rl_addons/rl_accel/_rl_accel.o
#6 11.37 error: command 'gcc' failed: No such file or directory
#6 11.37 [end of output]
```
🩹 These errors disappear when you add `gcc` and `freetype-devel` to the Dockerfile.
So for the same program to work on the Python 3.12 image, you have to modify your Dockerfile so in its final state looks like this:
```Dockerfile
# FROM public.ecr.aws/lambda/python:3.12.2025.01.24.11-arm64
FROM public.ecr.aws/lambda/python:3.12.2025.01.24.11-x86_64
RUN dnf install -y freetype-devel gcc
RUN pip install -U pip && pip install reportlab==3.6.13
ENTRYPOINT ["python", "-c", \
"from reportlab.pdfgen import canvas; \
c = canvas.Canvas('test.pdf'); \
c.drawString(100,100,'Hello World'); c.save(); \
print('PDF generated as test.pdf')"]
```
---
⚠️⚠️⚠️
Is lack of these packages intentional or is this a bug and they will be added❓
⚠️⚠️⚠️
Contributor guide
Assessment
This issue has not been assessed yet.