> ## Documentation Index
> Fetch the complete documentation index at: https://bakefile.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Package

> A pyproject-based Python package managed with PythonSpace. Inherited tasks, one override, one custom task.

The [`python-package` example](https://github.com/wislertt/bakefile/tree/main/examples/python-package) is a normal `uv` package (src layout, `pyproject.toml`, tests) whose `bakefile.py` inherits [PythonSpace](/bakelib/spaces) instead of writing tasks from scratch:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from bake import command, console
from bakelib import PythonSpace


class MyBakebook(PythonSpace):
    def _get_mise_tools(self) -> set[str]:
        mise_tools = super()._get_mise_tools()
        mise_tools.remove("pipx:bakefile")
        return mise_tools

    # Override an inherited task: same tests, but stop at the first failure
    def test(self) -> None:
        self._test(tests_paths="tests/", extra_args="-x")

    # A project-specific task on top of the space
    @command(help="Build the package into dist/")
    def build(self) -> None:
        self.ctx.run("uv build")


bakebook = MyBakebook()


@bakebook.command()
def hello(name: str = "world"):
    console.echo(f"Hello {name}!")
```

## What it shows

* Inheriting a Space: `lint`, `test`, `setup-dev`, `tools`, `update`, `version`, `clean`, and more arrive preconfigured (ruff, ty, deptry, pytest with coverage, uv).
* Overriding one inherited task. `test` reuses the space's own `_test` helper with `extra_args="-x"` to stop at the first failure. No `@command()` needed, the inherited registration carries over.
* Adding a project-specific task (`build`) with `@command()` as usual.
* A private hook tweak: `_get_mise_tools` drops `pipx:bakefile` because this project gets bakefile from its own venv (`bakefile[lib]` in `pyproject.toml`), so the pipx copy would be redundant.

## Try it

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
cd examples/python-package
bake setup-dev    # install tools, create venv, install pre-commit
bake lint         # prettier, toml-sort, ruff format, ruff, ty, deptry
bake test         # pytest with coverage, stops at first failure (the override)
bake build        # uv build into dist/
```
