the complementary task runner for python poetry projects
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:
poetry 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.6 or newer.
Your project directory should include a valid pyproject.toml file, as specified in PEP-518.
Usage
Installation
To install taskipy as a dev dependency, simply run:
poetry add --dev taskipy
Adding Tasks
In your pyproject.toml file, add a new section called [tool.taskipy.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.taskipy.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:
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.taskipy.tasks]
lint_pylint = "pylint tests taskipy"
lint_mypy = "mypy tests taskipy"
And then create a composite task:
[tool.taskipy.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.taskipy.tasks]
test = "python -m unittest tests/test_*.py"
build = "make ."
You could make tests depend on building, by using the pretask hook:
[tool.taskipy.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.taskipy.tasks]
test = "python -m unittest tests/test_*.py"
lint = "pylint tests taskipy"
You could make tests trigger linting, by using the posttask hook:
[tool.taskipy.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.
Using Taskipy Without Poetry
Taskipy was created with poetry projects in mind, but actually only requires a valid pyproject.toml file in your project's directory. As a result, you can use it even eithout poetry:
Installing With PIP
Install taskipy on your machine or in your virtualenv using:
pip install taskipy
Running Tasks
Head into your project's directory (don't forget to activate virtualenv if you're using one), and run the following command:
task TASK
Where TASK is the name of your task.
Metadata
Release files for taskipy 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| taskipy-1.0.2.tar.gz | 4.7 kB | Without provenance | Details for taskipy-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| taskipy-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for taskipy-1.0.2-py3-none-any.whl |
Total release size: 9.5 kB
Release files / taskipy-1.0.2.tar.gz
| Download URL | taskipy-1.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
211bd7a7af4b73faaf20042547be7d0c12b9ff91efd548d626c340f6cba5b34b
|
|
BLAKE2b-256 checksum How to use checksums |
78bf76e9b0d4092c57b5455f12ebe7c145a01619f156c62d3701cac99de1db0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.7.5 Darwin/18.0.0
|
Release files / taskipy-1.0.2-py3-none-any.whl
| Download URL | taskipy-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e088b054eee40c411f320f19137f6c3c29afaa1530306f012a3b0d543010deb7
|
|
BLAKE2b-256 checksum How to use checksums |
d5a074bd8629e4fe3967e735a4a1f80bf4b20a4b065945cb826b81187414c6a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.7.5 Darwin/18.0.0
|
Security for taskipy 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.