Open ibuildthecloud opened 3 weeks ago
FWIW, python 3.13 does not exhibit this behavior, it works fine. I've just switched to python 3.13 for the short term.
Can you check if you have the latest Wolfi-base
@ibuildthecloud did you re-pull latest cgr.dev/chainguard/wolfi-base? (no cache, to get openssl 3.4.0) as I expect sha256 to be always available..... from openssl...... which is where python gets those hash implementations from....
But will retest all combinations too.
I reproduced exactly the above error locally. Then a docker system prune --volumes --all
followed by another attempt made it go away.
The wolfi-base I had cached locally was cgr.dev/chainguard/wolfi-base@sha256:d6b37317ae7cb5c0864189e9e5acd825386ae226a413e7c19370f5f87d150f92
$ img=cgr.dev/chainguard/wolfi-base@sha256:d6b37317ae7cb5c0864189e9e5acd825386ae226a413e7c19370f5f87d150f92
$ docker run -it --rm --entrypoint="" "$img" \
sh -c 'apk add python-3.12-base && python3.12 -c "import hashlib"'
...
(14/14) Installing python-3.12-base (3.12.7-r1)
...
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/lib/python3.12/hashlib.py", line 245, in <module>
globals()[__func_name] = __get_hash(__func_name)
^^^^^^^^^^^^^^^^^^^^^^^
...
libssl3 and libcrypto3 are backwards compatible, but not forwards compatible.
This is easiest to demonstrate with just the openssl command in the base image that @smoser posted
$ docker run --rm -ti --entrypoint sh cgr.dev/chainguard/wolfi-base@sha256:d6b37317ae7cb5c0864189e9e5acd825386ae226a413e7c19370f5f87d150f92
/ # apk add openssl~3.0
fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
(1/1) Installing openssl (3.0.7-r3)
WARNING: Support for packages with multiple data parts will be dropped in apk-tools 3.
OK: 16 MiB in 15 packages
/ # openssl version
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.3.1 4 Jun 2024)
/ # apk add openssl~3.1
(1/2) Installing openssl-provider-legacy (3.4.0-r1)
(2/2) Upgrading openssl (3.0.7-r3 -> 3.1.4-r1)
OK: 16 MiB in 16 packages
/ # openssl version
OpenSSL 3.1.4 24 Oct 2023 (Library: OpenSSL 3.3.1 4 Jun 2024)
/ # apk add openssl~3.2
(1/1) Upgrading openssl (3.1.4-r1 -> 3.2.1-r0)
OK: 16 MiB in 16 packages
/ # openssl version
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)
/ # apk add openssl~3.3
(1/1) Upgrading openssl (3.2.1-r0 -> 3.3.2-r2)
OK: 16 MiB in 16 packages
/ # openssl version
OpenSSL 3.3.2 3 Sep 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)
/ # apk add openssl~3.4
(1/1) Upgrading openssl (3.3.2-r2 -> 3.4.0-r1)
OK: 16 MiB in 16 packages
/ # openssl version
openssl: /usr/lib/libssl.so.3: version `OPENSSL_3.4.0' not found (required by openssl)
openssl: /usr/lib/libcrypto.so.3: version `OPENSSL_3.4.0' not found (required by openssl)
/ # apk add -u libcrypto3 libssl3
(1/2) Upgrading libcrypto3 (3.3.1-r4 -> 3.4.0-r1)
(2/2) Upgrading libssl3 (3.3.1-r4 -> 3.4.0-r1)
OK: 15 MiB in 16 packages
/ # openssl version
OpenSSL 3.4.0 22 Oct 2024 (Library: OpenSSL 3.4.0 22 Oct 2024)
/ # exit 0
As you can see openssl binary 3.0 through to 3.3 work correctly against 3.3.1 libraries. However openssl binary 3.4 fails against 3.3.1 libraries, unless they are upgraded.
Unfortunately, with python the runtime traceback is incomprehensible, to understand that libcrypto/libssl is out of date in the image.
The solution is to either upgrade the libcrypto3 and libssl3; or to pull a newer base image.
@ibuildthecloud Can you please confirm that executing docker pull cgr.dev/chainguard/wolfi-base:latest
resolve the compatibility with python-3.12 for you? Since you show dockerfile, please ensure you always use docker build --no-cache --pull
such that no cached results are used; and that base image is always attempted to be pulled to avoid such issues ever again.
To make this better in the future, opened melange issue https://github.com/chainguard-dev/melange/issues/1621
If you run the following Dockerfile you'll see that python3.12 on arm64 hashlib is somehow broken.
Output