Back
+20 XP
Concept

Build Backends: Hatchling vs Flit vs Setuptools

PEP 517 decoupled package frontends (`pip`, `uv`) from backends. Backends package source code into deployable wheel (`.whl`) and sdist (`.tar.gz`) archives: Flit for simplicity, Hatchling for modern projects, and Setuptools for C extensions ⚙️.

python
backends = {
    "flit": "flit_core.buildapi",
    "hatch": "hatchling.build",
    "setuptools": "setuptools.build_meta",
    "maturin": "maturin"
}

for tool, hook in backends.items():
    print(f"Tool: {tool:<10} -> Hook: {hook} ⚙️")

# 92. Build Backends: Hatchling vs Flit vs Setuptools PEP 517 decoupled package frontends (`pip`, `uv`) from backends. Backends package source code into deployable wheel (`.whl`) and sdist (`.tar.gz`) archives: Flit for simplicity, Hatchling for modern projects, and Setuptools for C extensions ⚙️. ```python backends = { "flit": "flit_core.buildapi", "hatch": "hatchling.build", "setuptools": "setuptools.build_meta", "maturin": "maturin" } for tool, hook in backends.items(): print(f"Tool: {tool:<10} -> Hook: {hook} ⚙️") ``` For high-performance compiled extensions in Rust, Maturin integrates PyO3 with `pyproject.toml` so your Rust crates compile into native Python wheels with zero C boilerplate 🏎️! --- ### Question What is the primary responsibility of a PEP 517 build backend when building a Python package? 🧠 - [ ] a. Generating standard distribution archives (binary `.whl` and source `.tar.gz` sdist) from source code ⚙️ - [ ] b. Registering domain names for package documentation websites - [ ] c. Enforcing git branch protection rules on remote repositories - [ ] d. Translating Python syntax trees into JavaScript bundles --- ### Challenge Given `backends = {'hatch': 'hatchling.build', 'flit': 'flit_core.buildapi'}`, access and print the hook for `'hatch'`. 🎯 <details> <summary>Solution</summary> ```python backends = {'hatch': 'hatchling.build', 'flit': 'flit_core.buildapi'} print(backends['hatch']) ``` </details>

Checkpoint

What is the primary responsibility of a PEP 517 build backend when building a Python package? 🧠

Practice

Given `backends = {'hatch': 'hatchling.build', 'flit': 'flit_core.buildapi'}`, access and print the hook for `'hatch'`. 🎯

Terminal
01
Tap code blocks below to assemble
Available Blocks