What is a wheel vs an sdist?
IntermediateConceptEnvironments, dependencies & packaging
Answer
- sdist (
.tar.gz): source distribution; installing it runs a build step, which for C extensions needs a compiler and headers. - wheel (
.whl): a pre-built zip that is simply unpacked into site-packages. Pure-Python wheels arepy3-none-any; binary wheels carry platform tags likemanylinux_2_28_x86_64ormusllinux_1_2_aarch64.
pip prefers wheels. When none matches your platform (Alpine/musl, new Python versions, ARM), it falls back to the sdist and compiles, which is why pip install on Alpine can take 20 minutes or fail with gcc: not found.
More on Environments, dependencies & packaging
What is a virtual environment and why do we always use one?BeginnerWhat does `error: externally-managed-environment` mean?Beginner`requirements.txt` vs `pyproject.toml`: what goes where?IntermediateWhy is `pip freeze > requirements.txt` not a great lock strategy?IntermediateWhat do version specifiers like `~=`, `==`, `>=,<` mean?BeginnerWhat are `pipx` and `uv`, and when do you use them?Intermediate