Skip to content

Lesson 1 of 9 · 20m

What You Actually Ship: sdists, Wheels, and Metadata

The difference between source trees, sdists, and wheels — and why understanding the artifact saves you hours of dependency debugging.

The first packaging mistake is thinking you publish your repository. You don't. You publish artifacts built from it, and those artifacts are what pip downloads, unpacks, and installs. Once you internalize that, most packaging mysteries stop being mysterious.

A package is an artifact, not a folder

Your source tree is the input. A source distribution (sdist) is a tarball of the source needed to build the project. A wheel is the preferred install format: prebuilt, unpacked by pip without running arbitrary build code.

mylib-1.4.2.tar.gz                         # sdist
mylib-1.4.2-py3-none-any.whl               # pure-Python wheel
mylib-1.4.2-cp312-cp312-manylinux_2_17_x86_64.whl

The wheel filename is a compatibility contract. py3-none-any means any Python 3, any ABI, any platform. A compiled wheel names the Python implementation, ABI, and platform tags explicitly. If pip cannot find a compatible wheel, it falls back to building the sdist — which is when missing compilers and headers become user-visible failures.

pip installs metadata first

Inside a wheel, pip reads the .dist-info directory:

mylib-1.4.2.dist-info/
  METADATA       # name, version, dependencies, classifiers
  WHEEL          # wheel format details
  RECORD         # file list and hashes
  entry_points.txt

This is why dependency resolution happens before code execution. pip doesn't import your package to learn what it needs; it reads static metadata. Dynamic metadata is sometimes necessary, but every dynamic field adds a failure mode and makes builds less reproducible.

A clean local install test

python -m build
python -m venv /tmp/pkgtest
/tmp/pkgtest/bin/pip install dist/mylib-1.4.2-py3-none-any.whl
/tmp/pkgtest/bin/python -c "import mylib; print(mylib.__version__)"

Always test the artifact, not just the checkout. Editable installs hide missing files because your source tree is still there. A wheel test reveals whether package-data, typed marker files, templates, or generated modules were actually included.

Field notes

  • If installation works in your repo but fails in a fresh venv, suspect missing files in the sdist or wheel first.
  • pip install -e . is for development convenience, not proof that packaging is correct.
  • Inspect wheels with python -m zipfile -l dist/mylib-1.4.2-py3-none-any.whl.
  • Compiled wheels are distribution engineering, not a detail — platform tags and build environments decide whether users can install at all.

Was this lesson helpful?

Sign in to rate