What is a Python package?

A Python package is a collection of related code modules (files) bundled with metadata describing how the package should be installed and used.

There are three common formats for Python packages, each serving different purposes:

  • Wheels: Pre-built binary distributions that can be quickly installed with pip or uv.
  • Source distributions (sdists): Raw source code that may need to be built during installation
  • Conda packages: A format specific to the Conda ecosystem that can include non-Python components
Package vs Application Comparison

Packages and applications serve fundamentally different purposes:

Packages:

  • Provide reusable code modules/libraries
  • Focus on API design and documentation
  • Published to package indexes like PyPI
  • Carefully manage dependencies for compatibility
  • Designed to be imported by other Python code

Applications:

  • Have a main entry point (e.g., main.py or command-line interface)
  • Focus on end-user functionality
  • Often include configuration files and user settings
  • May bundle dependencies for deployment
  • Typically not imported by other Python code

Compiled vs Non-Compiled Python Packages

Python packages may or may not include extensions written in languages other than Python, e.g., C, C++, and Rust. The distinction between wheels and source distributions is most pertinent when extensions are included. Source distributions include the raw extension source code, which must be compiled at installation time, while wheels (as well as Conda packages) include pre-compiled binary versions.

Build Backends, Frontends, and Package Managers

Several types of tools are involved in the construction and installation of packages:

Last updated on

Please submit corrections and feedback...