Interview frequency: …
Short answer
A wheel is a built package ready to install by just copying files, while an sdist is a source archive that needs a build step on the user's machine and may need a compiler if it contains C extensions.
Explanation
Wheels install faster and run no build code, so they are safer and more predictable. Pure-Python packages produce a single wheel (py3-none-any), while packages with compiled extensions need a wheel per operating system, architecture, and Python version, usually built with tools such as cibuildwheel. Publish both on PyPI, and check the package contents before publishing.
Code example
python -m build
# dist/billing_service-1.4.0-py3-none-any.whl
# dist/billing_service-1.4.0.tar.gz
unzip -l dist/*.whl # Inspect the contents
python -m twine check dist/*Common mistakes
- Publishing only an sdist for a package with C extensions, so users must install a compiler.
- Publishing the package without inspecting its contents, so test files or secrets leak.