Registry / devops / python-tools-scripts

python-tools-scripts

JSON →
library0.20.5pypypi✓ verified 35d ago

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.

devops
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.203s · 44.5MB
glibc
py 3.103.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
Debug
Known footguns
gotchaThe PyPI package name is `python-tools-scripts`, but the Python import name for its modules is `ptscripts`. Attempting to import directly from `python_tools_scripts` will fail.
gotchaFor scripts to be discoverable by the `tools` CLI, they must reside within a Python package named `tools` at the root of your repository (e.g., `<repo-root>/tools/__init__.py`, `<repo-root>/tools/your_script.py`). Furthermore, the individual script files must be imported within `tools/__init__.py` to be loaded.
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.

Agent activity
13 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
Resources