doit - Automation Tool

0.37.0 · active · verified Mon Apr 13

doit is a Python-native task management and automation tool, similar to 'make' but entirely in Python. It allows users to define tasks as Python functions returning dictionaries, tracks file and task dependencies, caches results, and executes only what has changed, enabling incremental builds and reproducible workflows. As of version 0.37.0, it supports Python 3.10+ and is actively maintained with regular updates.

Warnings

Install

Imports

Quickstart

Create a file named `dodo.py` with task definitions. `doit` automatically discovers tasks named `task_*`. Tasks are Python functions that return a dictionary describing their actions, dependencies (`file_dep`), and outputs (`targets`). Running `doit` from the command line executes these tasks, honoring dependencies and skipping up-to-date tasks.

import os

def task_hello():
    """create a greeting file"""
    return {
        'actions': ['echo "Hello from doit" > hello.txt'],
        'targets': ['hello.txt'],
        'clean': True,
    }

def task_shout():
    """convert greeting to uppercase"""
    return {
        'actions': ['tr a-z A-Z < hello.txt > shout.txt'],
        'file_dep': ['hello.txt'],
        'targets': ['shout.txt'],
        'clean': True,
    }

# To run this, save as dodo.py and execute in terminal:
# $ doit
# $ cat shout.txt
# $ doit clean
# (Note: 'tr' command is Unix-like, might need alternatives on Windows)

view raw JSON →