doit - Automation Tool
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
- breaking Version 0.37.0 dropped support for Python 3.8 and 3.9. The minimum required Python version is now 3.10. Prior versions also dropped support for older Python versions (e.g., 0.35.0 dropped 3.6/3.7).
- breaking Version 0.36.0 introduced several backward-incompatible changes, including the removal of the deprecated `doit.cmd_base.py:TaskLoader`, a switch from `toml` to `tomli` for configuration parsing, changes to how plugins are handled, and a restructuring of internal error classes (e.g., `CatchedException` renamed to `BaseFail`).
- gotcha Tasks without explicitly defined `file_dep` (file dependencies) or `targets` will always be considered 'out-of-date' and re-run every time `doit` is executed, even if their actions have no side effects. This can lead to unnecessary re-execution.
- gotcha Configuration files (`pyproject.toml`, `doit.cfg`, `dodo.py`'s `DOIT_CONFIG` variable) and command-line arguments have a specific precedence. Misunderstanding this hierarchy can lead to unexpected behavior where settings are not applied as intended, or `doit` fails to find tasks.
Install
-
pip install doit
Imports
- Task Definition
def task_my_task(): return {'actions': ['echo "hello"']} - doit.tools
from doit.tools import result_dep
- DOIT_CONFIG
DOIT_CONFIG = {'verbosity': 2}
Quickstart
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)