Python Tools Scripts (ptscripts) is a command-line interface (CLI) tool designed to simplify the creation and management of project-specific scripts. It functions similarly to `invoke` but leverages `argparse` internally for CLI argument definition. The library discovers and integrates scripts placed within a designated 'tools' package in a repository's root, making them accessible via a central `tools` command. It is currently at version 0.20.5 and appears to have an active maintenance cadence, with the latest release in early 2024.
Install & Compatibility
Where this runs
tested against v0.20.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 1.203s · 44.5MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 5.0s · import 1.104s · 44MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from ptscripts import Context
from ptscripts import command_group
The installed package is `python-tools-scripts`, but the actual import module is `ptscripts`. Importing `python_tools_scripts` directly will not provide the intended API.
from ptscripts import command
To use `python-tools-scripts`, create a `tools` directory in your repository's root and ensure it's a Python package (contains `__init__.py`). Define your CLI commands within Python files inside this `tools` package using `@command_group` and `@command` decorators from `ptscripts`. These scripts will then be discoverable and executable via the `tools` command-line utility. Ensure you import your script files into `tools/__init__.py` for them to be picked up.
import os
from ptscripts import command_group, Context, command
# --- File: <repo-root>/tools/__init__.py ---
# This file makes the 'tools' directory a Python package.
# No specific content is required here for basic discovery, but it can import other scripts.
# --- File: <repo-root>/tools/my_scripts.py ---
# Define a command group
my_group = command_group(name="hello", help="Basic greeting commands")
@my_group.command(
arguments={
"name": {"help": "The name to greet", "default": "World"}
}
)
def greet(ctx: Context, name: str):
"""Greets the specified name."""
print(f"Hello, {name} from {ctx.command_path}!")
@my_group.command()
def goodbye(ctx: Context):
"""Says goodbye."""
print(f"Goodbye from {ctx.command_path}!")
# To make 'my_scripts.py' discoverable by the 'tools' CLI,
# ensure it's imported in '<repo-root>/tools/__init__.py'.
# E.g., 'from . import my_scripts'
# --- How to run (from your repository root) ---
# Make sure to run 'pip install python-tools-scripts' first.
# > tools hello greet --name Alice
# > tools hello goodbye
tools --version
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.