Run scripts defined in a project's pyproject.toml (like npm run)
Project description
pyproject-scripts (pps)
Tiny, dependency‑free project‑local script runner for Python projects: declare scripts in pyproject.toml under [tool.scripts.*], get instant pps <name> subcommands.
Installation
# Install from PyPI
pip install pyproject-scripts
# editable / dev inside a cloned repo
pip install -e .
# or with uv
uv pip install -e .
Defining Scripts
Define scripts in pyproject.toml under the [tool.scripts] table according to this schema:
[tool.scripts.<your-script-name>]
cmd = "<your command here>"
description = "<short description>"
cwd = "<optional working directory>"
env = { "<VAR>" = "<value>", ... }
shell = true | false
The meaning of each field is as follows:
| Field | Required | Type | Description |
|---|---|---|---|
cmd |
Yes | string | Command to execute (interpreted by shell unless shell=false). |
description |
No | string | Short human description shown in help listing. |
cwd |
No | string | Working directory (relative to discovered project root) or absolute path. |
env |
No | table | Extra environment vars (stringified) layered over current env. |
shell |
No | bool | true/omitted: run via shell. false: tokenize with shlex.split and exec directly. |
Usage Examples
Here's an example pyproject.toml snippet defining two scripts, lint and test:
[tool.scripts.lint]
cmd = "ruff check . && ruff format --check ."
description = "Run ruff linter"
cwd = "src"
env = { "RUST_LOG" = "info" }
shell = true
[tool.scripts.test]
cmd = "pytest -q"
description = "Run test suite"
shell = false
To run the lint script, simply execute:
pps lint
Additional arguments can be passed, for example to run a specific test file. Every argument after the script name is forwarded to the command:
pps test tests/test_special_case.py
Supported Python Versions
Tested on CPython >= 3.11. Older versions are not targeted because tomllib, used for parsing pyproject.toml, is only in the standard library since 3.11.
License
AGPL-3.0-or-later. See LICENSE for full text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyproject_scripts-0.1.0.tar.gz.
File metadata
- Download URL: pyproject_scripts-0.1.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ad3714dc9100bb91d1a0a141a36c6624dd9a8cfa66595908aac90e7f65caff9
|
|
| MD5 |
8cd6b5566885020ecb0279688351cdce
|
|
| BLAKE2b-256 |
7865543d57a148a7f72e97592eb40d26006e546346362d4b017a969552d7060c
|
Provenance
The following attestation bundles were made for pyproject_scripts-0.1.0.tar.gz:
Publisher:
release.yml on okleinke/pyproject-scripts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyproject_scripts-0.1.0.tar.gz -
Subject digest:
3ad3714dc9100bb91d1a0a141a36c6624dd9a8cfa66595908aac90e7f65caff9 - Sigstore transparency entry: 453061397
- Sigstore integration time:
-
Permalink:
okleinke/pyproject-scripts@85a636f41596730a8b4074820ccd7ee09e99ffa5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/okleinke
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@85a636f41596730a8b4074820ccd7ee09e99ffa5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyproject_scripts-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyproject_scripts-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77cb2967e8ada1f6a0c023074dfa08a2f6f106f3ac43d6d2509a56eb8272b644
|
|
| MD5 |
d8df0f8ceae2a1890a92ec774dd2b21d
|
|
| BLAKE2b-256 |
8095816919f18270ffc7f3986643f5fb94977ae33290b2e2f6872360db0ad6bb
|
Provenance
The following attestation bundles were made for pyproject_scripts-0.1.0-py3-none-any.whl:
Publisher:
release.yml on okleinke/pyproject-scripts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyproject_scripts-0.1.0-py3-none-any.whl -
Subject digest:
77cb2967e8ada1f6a0c023074dfa08a2f6f106f3ac43d6d2509a56eb8272b644 - Sigstore transparency entry: 453061428
- Sigstore integration time:
-
Permalink:
okleinke/pyproject-scripts@85a636f41596730a8b4074820ccd7ee09e99ffa5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/okleinke
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@85a636f41596730a8b4074820ccd7ee09e99ffa5 -
Trigger Event:
push
-
Statement type: