What is a Python package?
A Python package is code designed to be imported by other Python programs, bundled with metadata so it can be discovered, installed, and version-managed by tools like pip or uv.
This is different from a Python application, which is a program end users run directly. Django is a package; a Django-powered website is an application. Requests is a package; a script that calls requests.get() is an application.
What format does a Python package come in?
Python packages reach users in two standard formats on PyPI:
- Wheels (
.whl): pre-built binary distributions. pip and uv install them by copying files into place with no build step, making installation fast even on machines without a compiler. - Source distributions (sdists) (
.tar.gz): raw source code. Installing from an sdist requires running the build backend to produce an installable artifact.
Most packages on PyPI publish both. The wheel installs fast on supported platforms; the sdist provides a fallback for platforms with no matching wheel.
Conda packages are a third format used in the conda ecosystem. Unlike wheels and sdists, conda packages can include non-Python components such as native libraries.
Does a Python package need compilation?
A package that contains only .py files is platform-independent: one wheel tagged py3-none-any installs on any platform and Python 3 version.
A package with extensions written in C, C++, Cython, or Rust requires compilation. The resulting wheel is tied to a specific platform and Python version (e.g., cp312-manylinux_2_17_x86_64). For these packages, maintainers typically build wheels for multiple targets in CI using cibuildwheel and upload all of them to PyPI.
What tools build and install packages?
Three categories of tools turn source code into an installable package:
- A build backend (setuptools, hatchling, flit) produces the wheel or sdist from source code.
- A build frontend (uv, build) coordinates the process, sets up an isolated build environment, and invokes the backend.
- A package manager (uv, pip) resolves and installs dependencies into virtual environments.
Learn More
- What is a Python application? explains the related concept and why the distinction matters for tooling
- What is a wheel? covers the binary distribution format in detail
- What is a build backend? explains setuptools, hatchling, and the alternatives
- Build and publish a Python package is a hands-on tutorial that walks through the full process