Automation tool that brings the power of build-tools to execute any kind of task with efficient DAG-based execution and plugin architecture
npx @tessl/cli install tessl/pypi-doit@0.36.0A powerful automation tool that brings the concept of build tools to execute any kind of task. doit scales from simple task runners for organizing project-related tasks to efficient build-tool execution with DAG (Direct Acyclic Graph) creation and task result caching, ensuring only required tasks are executed in the correct order for incremental builds.
pip install doitcloudpickle, importlib-metadata>=4.4tomli for TOML config support (Python < 3.11)import doitFor programmatic API usage:
from doit import run, get_var, create_after, task_params, Globals
from doit.api import run_tasks
from doit.tools import config_changed, timeout, LongRunning, Interactivedef task_hello():
"""Say hello"""
return {
'actions': ['echo "Hello World!"'],
'verbosity': 2,
}
def task_compile():
"""Compile source files"""
return {
'file_dep': ['src/main.c'],
'targets': ['build/main.o'],
'actions': ['gcc -c src/main.c -o build/main.o'],
}# List available tasks
doit list
# Run all tasks
doit
# Run specific task
doit hellofrom doit import run
# Define tasks in current module
def task_example():
return {'actions': ['echo "Running example"']}
# Run tasks programmatically
if __name__ == '__main__':
run(globals())doit follows a plugin-based architecture with several key components:
This design enables doit to serve both as a simple task runner and as a framework for building complex automation workflows and pipelines.
Primary programmatic interface for running tasks and accessing doit functionality directly from Python code.
def run(task_creators):
"""Run doit using task_creators from module or dict"""
def get_var(name, default=None):
"""Get command line variable values"""
def get_initial_workdir():
"""Get working directory from where doit command was invoked"""Functions and decorators for defining tasks, managing delayed task creation, and parameterizing task generators.
@create_after(executed=None, target_regex=None, creates=None)
def task_creator_func():
"""Decorator for delayed task creation"""
@task_params(param_def)
def task_creator_func():
"""Decorator for task parameter definitions"""
def load_tasks(namespace, command_names=(), allow_delayed=False, args=(), config=None, task_opts=None):
"""Find task-creators and create tasks from namespace"""Classes and utilities for defining task actions, including shell commands, Python functions, and specialized interactive actions.
class LongRunning(CmdAction):
"""Handle long running shell processes (servers/services)"""
class Interactive(CmdAction):
"""Handle interactive shell processes"""
class PythonInteractiveAction(PythonAction):
"""Handle interactive Python actions"""Helper functions and classes for common task patterns, uptodate checkers, and development utilities.
def create_folder(dir_path):
"""Create folder if it doesn't exist"""
class config_changed:
"""Check if configuration was modified (uptodate checker)"""
class timeout:
"""Add timeout to task (uptodate checker)"""
def set_trace():
"""Start debugger with proper stdout"""Complete command-line interface with extensible commands, configuration management, and plugin system.
class DoitMain:
"""Main CLI application class"""
class DoitConfig:
"""Parse and store INI/TOML configuration"""
# Available commands: run, list, clean, info, help, forget, ignore, dumpdb, strace, completion, resetdepComprehensive exception hierarchy for task failures, configuration errors, and execution problems.
class InvalidTask(Exception):
"""Invalid task instance"""
class TaskFailed(BaseFail):
"""Task execution was not successful"""
class TaskError(BaseFail):
"""Error while trying to execute task"""class Task:
"""Main task abstraction with actions, dependencies, targets"""
class DelayedLoader:
"""Contains info for delayed creation of tasks from task-creator"""
class Globals:
"""Registry of singletons for accessing dep_manager"""
dep_manager = None # Dependency manager instance