DevOps & Cloud

invoke

Turn your messy folder of shell scripts into a tidy, single command anyone on the team can run.

Install it: pip install invoke

What does it do?

Invoke lets developers define common tasks, like running tests, building docs, or cleaning up temp files, as plain Python functions, then run them from the command line by name. It’s essentially a replacement for the decades-old Makefile approach to task automation, except the tasks are written in Python instead of a cryptic scripting language. Type invoke test instead of remembering the exact three-line incantation that runs the test suite correctly.

See it in action

This is a task file defining two shortcuts — typing ‘invoke build’ builds the project and ‘invoke test’ runs its tests — instead of typing out the full commands each time.

from invoke import task

@task
def build(c):
    c.run("python setup.py build")

@task
def test(c):
    c.run("pytest tests/")

Why would a non-developer care?

Every software project accumulates a pile of routine chores, and without a shared way to run them, that knowledge lives in someone’s head or a forgotten wiki page. Tools like Invoke turn asking a coworker how to build the project into a command anyone new to the team can run on day one.

Real-world examples

Invoke grew out of the same ecosystem as Fabric, and Fabric now actually uses Invoke’s task-running engine internally, both created by the same maintainer. Teams that skip a task runner tend to end up with a README full of copy-pasted shell commands that quietly go stale as the project evolves, which is exactly the failure mode Invoke prevents.

Who uses it

Python developers who want a clean, shareable way to define and run project tasks like testing, building, and deployment steps.

How it compares to alternatives

It plays a similar role to Makefiles or npm scripts in other ecosystems, but with the full power of Python behind each task instead of a limited scripting syntax. Fabric extends Invoke specifically for remote-server tasks over SSH.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries