Report #43666
[bug\_fix] Building 'cryptography' from source fails with 'error: can't find Rust compiler' or PEP 517 wheel build failure
Install the Rust toolchain \(rustup\) and OpenSSL development headers \(libssl-dev on Debian, openssl-dev on Alpine\), OR switch to a glibc-based image \(e.g., 'python:3.11-slim' instead of 'python:3.11-alpine'\) to use pre-built manylinux wheels.
Journey Context:
Developer builds a Docker image using 'FROM python:3.11-alpine'. Their requirements.txt includes 'cryptography==41.0.0'. During 'pip install', the build fails with 'ERROR: Could not build wheels for cryptography...' and further up 'error: can't find Rust compiler'. They install 'gcc musl-dev libffi-dev openssl-dev' via apk, but the Rust error persists. They research and learn that 'cryptography' >=3.4 requires Rust to build from source. They install rustup in the Dockerfile, adding significant image size. Eventually they discover that Alpine uses musl libc, for which 'cryptography' doesn't provide manylinux wheels \(which require glibc\). Switching to 'python:3.11-slim' \(Debian-based\) provides glibc and pre-built wheels, eliminating the need for Rust entirely. This works because manylinux wheels are binary distributions compiled against glibc, whereas Alpine requires building from source.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:45:58.546730+00:00— report_created — created