Skip to main content

Modern Python task runner - npm scripts for Python

Project description

taskx - Modern Python Task Runner

npm scripts for Python. Task automation that just works.

PyPI Python License Tests


๐ŸŽ‰ What's New in v0.2.0

  • Shell Completion - TAB completion for commands and tasks in bash, zsh, fish, and PowerShell
  • Task Aliases - Create short names for frequently used tasks (e.g., t for test)
  • Interactive Prompts - Ask for user input and confirmations during task execution
  • Project Templates - Kickstart projects with 4 production-ready templates (Django, FastAPI, Data Science, Python Library)

See full changelog | Upgrade guide


โœจ Why taskx?

Stop fighting with Makefiles. taskx brings the simplicity of npm scripts to Python with the power you actually need.

# pyproject.toml
[tool.taskx.tasks]
test = "pytest tests/"
dev = "uvicorn app:app --reload"
lint = "ruff check ."

deploy = {
    depends = ["lint", "test", "build"],
    cmd = "twine upload dist/*"
}
$ taskx list
Available tasks:
  test       Run test suite
  dev        Start development server
  lint       Run linting
  deploy     Deploy to PyPI

$ taskx deploy
โ†’ Running: lint
โœ“ Completed: lint (1.2s)
โ†’ Running: test
โœ“ Completed: test (3.4s)
โ†’ Running: build
โœ“ Completed: build (2.1s)
โ†’ Running: deploy
โœ“ Completed: deploy (0.8s)

๐Ÿš€ Quick Start

Installation

pip install taskx

Requirements: Python 3.8 or higher

Verify Installation

$ taskx --version
taskx version 0.2.0

Initialize

Create a new project with a template:

# List available templates
$ taskx init --list-templates
Available templates:

  WEB:
    django               Django web application with migrations, testing, and deployment
    fastapi              FastAPI microservice with async support and Docker

  DATA:
    data-science         ML project with Jupyter, MLflow, and pipeline automation

  LIBRARY:
    python-library       Python package with PyPI publishing workflow

# Create project from template
$ taskx init --template django --name myproject
โœ“ Created django project with taskx configuration

# Or create a basic project
$ taskx init
โœ“ Created pyproject.toml with example tasks

Define Tasks

Add tasks to your pyproject.toml:

[tool.taskx.tasks]
hello = "echo 'Hello from taskx!'"
test = "pytest"
dev = "python manage.py runserver"

Run Tasks

$ taskx hello
Hello from taskx!

$ taskx test
===== test session starts =====
...

๐ŸŽฏ Features

โœ… Python-Native

  • Uses pyproject.toml (Python standard)
  • Integrates with Poetry, Hatch, PDM
  • No new config files needed

โœ… Cross-Platform

  • Perfect Windows support (no Make headaches!)
  • Works on macOS, Linux, Windows
  • Consistent behavior everywhere

โœ… Task Dependencies

[tool.taskx.tasks]
lint = "ruff check ."
test = "pytest"
deploy = { depends = ["lint", "test"], cmd = "python deploy.py" }

โœ… Parallel Execution

[tool.taskx.tasks]
check = {
    parallel = ["ruff check", "mypy .", "pytest --quick"],
    description = "Run all checks in parallel"
}

3-4x faster than running sequentially!

โœ… Environment Variables

[tool.taskx.env]
APP_NAME = "myapp"
PORT = "8000"

[tool.taskx.tasks]
dev = "uvicorn ${APP_NAME}:app --port ${PORT}"
prod = { cmd = "uvicorn ${APP_NAME}:app", env = { PORT = "80" } }

โœ… Hooks & Watch Mode

[tool.taskx.tasks]
test = { cmd = "pytest", pre = "echo 'Starting tests...'", post = "coverage report" }

dev = { cmd = "uvicorn app:app --reload", watch = ["**/*.py"] }

Run watch mode:

$ taskx watch dev
๐Ÿ‘€ Watching for changes...
โ–ถ Running initial execution...
โœ“ Initial execution completed

๐Ÿ“ Detected 1 change(s):
   โ†’ src/app.py
โ–ถ Re-running task 'dev'...
โœ“ Execution completed successfully

โœ… Beautiful Output

  • Color-coded task status
  • Progress bars for parallel tasks
  • Helpful error messages
  • Time tracking

โœ… Shell Completion (NEW in v0.2.0)

# Install completion for your shell
$ taskx completion bash --install
โœ“ Completion installed: ~/.bash_completion.d/taskx

# Now get TAB completion for tasks!
$ taskx <TAB>
list  run  watch  graph  init  completion
$ taskx run <TAB>
test  dev  lint  deploy

Supports: bash, zsh, fish, PowerShell

โœ… Task Aliases (NEW in v0.2.0)

[tool.taskx.aliases]
t = "test"
d = "dev"
fmt = "format"

[tool.taskx.tasks]
test = { cmd = "pytest", aliases = ["t"] }  # Per-task alias
format = "black . && isort ."
$ taskx t  # Runs 'test'
โ†’ Alias 't' resolves to task 'test'
===== 51 tests passed =====

โœ… Interactive Prompts (NEW in v0.2.0)

[tool.taskx.tasks.deploy]
cmd = "sh deploy.sh ${ENVIRONMENT}"
prompt.ENVIRONMENT = {
    type = "select",
    message = "Deploy to which environment?",
    choices = ["staging", "production"]
}
confirm = "Deploy to ${ENVIRONMENT}?"
$ taskx deploy
? Deploy to which environment? (Use arrow keys)
  โ€บ staging
    production
? Deploy to staging? (Y/n) y
โ†’ Running: deploy
โœ“ Completed: deploy

โœ… Project Templates (NEW in v0.2.0)

# Start new Django project
$ taskx init --template django
# Prompts for project name, Celery, Docker options
# Generates complete project with 20+ tasks

# Start new FastAPI project
$ taskx init --template fastapi
# Creates API project with testing, Docker, database setup

# Start ML/Data Science project
$ taskx init --template data-science
# Jupyter, MLflow, complete ML pipeline

# Start Python library
$ taskx init --template python-library
# Package with PyPI publishing, testing, docs

๐Ÿ“Š Comparison

Feature taskx Make Poetry Scripts Invoke Taskipy
Python-native โœ… โŒ โœ… โœ… โœ…
Easy syntax โœ… โŒ โœ… โš ๏ธ โœ…
Cross-platform โœ… โš ๏ธ โœ… โœ… โœ…
Task dependencies โœ… โœ… โŒ โœ… โŒ
Parallel execution โœ… โœ… โŒ โœ… โŒ
Environment vars โœ… โœ… โŒ โœ… โŒ
Watch mode โœ… โŒ โŒ โŒ โŒ
Dependency graphs โœ… โŒ โŒ โŒ โŒ
Pre/post hooks โœ… โš ๏ธ โŒ โœ… โš ๏ธ
Shell completion โญ โœ… โš ๏ธ โŒ โš ๏ธ โŒ
Task aliases โญ โœ… โŒ โŒ โŒ โŒ
Interactive prompts โญ โœ… โŒ โŒ โš ๏ธ โŒ
Project templates โญ โœ… โŒ โŒ โŒ โŒ
Security focused โœ… โŒ โŒ โŒ โŒ

Legend: โœ… Full support | โš ๏ธ Partial support | โŒ Not supported | โญ New in v0.2.0


๐ŸŽ“ Examples

Django Project

[tool.taskx.tasks]
dev = "python manage.py runserver"
migrate = "python manage.py migrate"
shell = "python manage.py shell"
test = "pytest"
lint = { parallel = ["ruff check .", "mypy ."] }

Data Science Project

[tool.taskx.tasks]
notebook = "jupyter lab"
train = "python train_model.py"
evaluate = "python evaluate.py"
deploy = { depends = ["test", "evaluate"], cmd = "python deploy.py" }

FastAPI Application

[tool.taskx.env]
APP_MODULE = "app.main:app"

[tool.taskx.tasks]
dev = "uvicorn ${APP_MODULE} --reload"
prod = { cmd = "uvicorn ${APP_MODULE}", env = { WORKERS = "4" } }
test = "pytest tests/ -v"

More examples in examples/ directory.


๐Ÿ“š Documentation

Commands

  • taskx list - List all available tasks with descriptions and dependencies
    • taskx list --names-only - Output only task names (for shell completion)
    • taskx list --include-aliases - Include aliases in output
  • taskx <task> - Run a specific task (with automatic dependency resolution)
  • taskx run <task> - Explicit task execution
    • taskx run <task> --env KEY=VALUE - Override environment variables
  • taskx watch <task> - Watch files and auto-restart task on changes
  • taskx graph - Visualize task dependencies (supports tree, mermaid, dot formats)
  • taskx init - Initialize taskx configuration in your project
    • taskx init --template <name> - Create project from template โญ NEW
    • taskx init --list-templates - Show available templates โญ NEW
  • taskx completion <shell> - Generate shell completion script โญ NEW
    • taskx completion bash --install - Install completion for bash
    • Supported: bash, zsh, fish, powershell
  • taskx --version - Show version information
  • taskx --help - Show help for all commands

Graph Visualization

# Show ASCII tree of all tasks
$ taskx graph

# Show dependencies for specific task
$ taskx graph --task deploy

# Export as Mermaid diagram
$ taskx graph --format mermaid > tasks.mmd

# Export as Graphviz DOT
$ taskx graph --format dot > tasks.dot | dot -Tpng -o tasks.png

Configuration Reference

Basic Task

[tool.taskx.tasks]
hello = "echo 'Hello!'"

Task with Description

[tool.taskx.tasks]
test = { cmd = "pytest", description = "Run test suite" }

Task with Dependencies

[tool.taskx.tasks]
deploy = { depends = ["lint", "test"], cmd = "deploy.sh" }

Parallel Tasks

[tool.taskx.tasks]
check = { parallel = ["ruff", "mypy", "pytest"] }

Task with Environment Variables

[tool.taskx.tasks]
prod = { cmd = "uvicorn app:app", env = { PORT = "80", WORKERS = "4" } }

Task with Hooks

[tool.taskx.tasks]
test = "pytest"
test.pre = "echo 'Starting...'"
test.post = "coverage report"
test.on_error = "notify-send 'Tests failed!'"

Watch Mode

[tool.taskx.tasks]
dev = { cmd = "uvicorn app:app", watch = ["**/*.py"] }

Full documentation: GitHub Repository


๐Ÿ›ฃ๏ธ Roadmap

v0.1.0 โœ…

  • Core task execution with dependencies
  • Parallel task execution
  • Watch mode with file monitoring
  • Environment variable support
  • Lifecycle hooks (pre/post/error/success)
  • Dependency graph visualization
  • Multi-layer security validation
  • Beautiful terminal output
  • Cross-platform support

v0.2.0 (Current Release) โœ…

  • Shell completion scripts (bash, zsh, fish, PowerShell) โญ
  • Task aliases (global and per-task) โญ
  • Interactive prompts with confirmations โญ
  • Project templates (Django, FastAPI, Data Science, Python Library) โญ
  • Enhanced CLI with environment variable overrides
  • Template system with Jinja2 sandboxing
  • CI/CD-safe interactive prompt handling

v0.3.0 (Planned)

  • Task caching (skip unchanged tasks)
  • Remote task execution
  • Plugin system
  • Enhanced error recovery
  • Task profiling and performance analysis
  • Multi-project workspace support

See PHASE_1_IMPLEMENTATION_SUMMARY.md for v0.2.0 implementation details.


๐Ÿค Contributing

We love contributions! Check out our Contributing Guide.

Quick Links

Ways to Contribute

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ“ Improve documentation
  • ๐Ÿ”ง Submit pull requests
  • โญ Star the project!

๐Ÿ™‹ FAQ

Why not just use Make?

  • Make syntax is complex and error-prone (tabs!)
  • Poor Windows support
  • Not Python-native
  • taskx is simpler and more powerful

Why not Poetry scripts?

  • Poetry scripts are too basic (no dependencies, parallelization)
  • taskx is complementary - use Poetry for deps, taskx for tasks

Why not Invoke?

  • Invoke requires writing Python code for simple tasks
  • taskx uses declarative config (faster, simpler)
  • Use Invoke for complex logic, taskx for 90% of tasks

Can I use taskx with Poetry/Hatch/PDM?

  • Yes! taskx reads pyproject.toml and works with all tools

Does it work on Windows?

  • Yes! Cross-platform support designed from day one
  • Works on Windows, macOS, and Linux

How fast is it?

  • <100ms startup time
  • Parallel execution for independent tasks
  • Efficient file watching with Rust-based watchfiles library

Is it secure?

  • Yes! Multi-layer security validation
  • Prevents command injection attacks
  • Blocks dangerous patterns (rm -rf /, fork bombs, etc.)
  • Proper environment variable escaping
  • Optional strict mode for production

๐Ÿ“„ License

Proprietary License - taskx is free to use but comes with restrictions.

What You CAN Do:

  • โœ… Use taskx freely for personal or commercial projects
  • โœ… Install and run taskx without limitations
  • โœ… View the source code for reference and learning

What You CANNOT Do:

  • โŒ Modify the source code or create derivative works
  • โŒ Copy or redistribute the software
  • โŒ Remove or alter license notices or attribution
  • โŒ Create competing products based on taskx

Requirements:

  • โš ๏ธ Must preserve license notices - Cannot remove copyright or license information
  • โš ๏ธ Must include attribution - If using taskx in production, include: "Powered by taskx"

Full license terms: See LICENSE file for complete legal details.

Why proprietary? This license protects the integrity of taskx while allowing free usage. You get all the benefits without restrictions on how you use it, but the code itself remains protected from unauthorized modification or redistribution.


๐ŸŒŸ Star History

Star History Chart


๐Ÿ’ฌ Community


๐Ÿ™ Acknowledgments

Inspired by:

  • npm scripts - Simplicity and developer experience
  • Make - Power and reliability
  • Invoke - Python-native task execution
  • Poetry - Modern Python tooling

Built with:


Made with โค๏ธ for Python developers everywhere

Stop fighting with Makefiles. Start using taskx.

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

taskx-0.2.1.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

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

taskx-0.2.1-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

Details for the file taskx-0.2.1.tar.gz.

File metadata

  • Download URL: taskx-0.2.1.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for taskx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1659675bf5c653d0dd0f460f479a87c553b51ec384930adfde9e9fc2282d249d
MD5 337f30b04a7b3b2c28262078170e6d70
BLAKE2b-256 6974a4aacfc41f07d64d08eb0845dde2f6b175103fb907fb2b4a1bcbc54a7c7e

See more details on using hashes here.

File details

Details for the file taskx-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: taskx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 64.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for taskx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8ac9f2ea6e861884ddd8ee93897934efb06c7d6cc721dc4cf92ac4733852992
MD5 f70a14d2f843f86f1a5a88b40ca3a37a
BLAKE2b-256 6bf346cd25ed3c60a9809dd34439f5be5c53845224397a33aef608b9e994ecb0

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