Skip to main content

tasks runner for python projects

Project description

the complementary task runner for python

General

Every development pipeline has tasks, such as test, lint or publish. With taskipy, you can define those tasks in one file and run them with a simple command.

For instance, instead of running the following command:

python -m unittest tests/test_*.py

You can create a task called test and simply run:

task test

In addition, you can compose tasks and group them together, and also create dependencies between them.

This project is heavily inspired by npm's run script command.

Requirements

Python 3.5 or newer.

Your project directory should include a valid pyproject.toml file, as specified in PEP-518.

Usage

Installation

To install taskipy using pip, simply run:

pip install taskipy

With Poetry

If you're using poetry, add taskipy as a dev dependency:

poetry add --dev taskipy

Adding Tasks

In your pyproject.toml file, add a new section called [tool.taskify.tasks].

The section is a key-value map, from the names of the task to the actual command that should be run in the shell.

Example:

pyproject.toml

[tool.taskify.tasks]
test = "python -m unittest tests/test_*.py"
lint = "pylint tests taskipy"

Running Tasks

In order to run a task, run the following command in your terminal (or virtualenv):

task test

With Poetry

If you're using poetry, you can use its run function:

poetry run task test

Composing Tasks

Grouping Subtasks Together

Some tasks are composed of multiple subtasks. Instead of writing plain shell commands and stringing them together, you can break them down into multiple subtasks:

[tool.taskify.tasks]
lint_pylint = "pylint tests taskipy"
lint_mypy = "mypy tests taskipy"

And then create a composite task:

[tool.taskify.tasks]
lint = "task lint_pylint && task lint_mypy"
lint_pylint = "pylint tests taskipy"
lint_mypy = "mypy tests taskipy"

Pre Task Hook

Tasks might also depend on one another. For example, tests might require some binaries to be built. Take the two following commands, for instance:

[tool.taskify.tasks]
test = "python -m unittest tests/test_*.py"
build = "make ."

You could make tests depend on building, by using the pretask hook:

[tool.taskify.tasks]
pre_test = "task build"
test = "python -m unittest tests/test_*.py"
build = "make ."

The pretask hook looks for pre_<task_name> task for a given task_name. It will run it before running the task itself. If the pretask fails, then taskipy will exit without running the task itself.

Post Task Hook

From time to time, you might want to run a task in conjuction with another. For example, you might want to run linting after a successful test run. Take the two following commands, for instance:

[tool.taskify.tasks]
test = "python -m unittest tests/test_*.py"
lint = "pylint tests taskipy"

You could make tests trigger linting, by using the posttask hook:

[tool.taskify.tasks]
test = "python -m unittest tests/test_*.py"
post_test = "task lint"
lint = "pylint tests taskipy"

The posttask hook looks for post_<task_name> task for a given task_name. It will run it after running the task itself. If the task failed, then taskipy will not run the posttask hook.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskipy-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskipy-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file taskipy-1.0.0.tar.gz.

File metadata

  • Download URL: taskipy-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.8.0 Darwin/19.2.0

File hashes

Hashes for taskipy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9f21440490a199fa308d4e61b11bd4f308048f3b5f39b4c73abf966ac226909a
MD5 e5695407082f03cdff6b7c52dc0b32f7
BLAKE2b-256 486c8564c6c99d091bfeecd0ba7d90f41f502623f2fe336974ad31504bba4834

See more details on using hashes here.

File details

Details for the file taskipy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: taskipy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.8.0 Darwin/19.2.0

File hashes

Hashes for taskipy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7250c0b8e5b5ec38d969676e0ea4f0b92bbb7f3e41f43997f2977b8c4d94433
MD5 9f70bead9f2d6d338117d9ed7e383a0e
BLAKE2b-256 23a3e445e5e2877801cc12d65e04f424c423c153505413fac0396614b0692db8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page