Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyproject_scripts-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

pyproject_scripts-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

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

Hashes for pyproject_scripts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ad3714dc9100bb91d1a0a141a36c6624dd9a8cfa66595908aac90e7f65caff9
MD5 8cd6b5566885020ecb0279688351cdce
BLAKE2b-256 7865543d57a148a7f72e97592eb40d26006e546346362d4b017a969552d7060c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyproject_scripts-0.1.0.tar.gz:

Publisher: release.yml on okleinke/pyproject-scripts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyproject_scripts-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyproject_scripts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77cb2967e8ada1f6a0c023074dfa08a2f6f106f3ac43d6d2509a56eb8272b644
MD5 d8df0f8ceae2a1890a92ec774dd2b21d
BLAKE2b-256 8095816919f18270ffc7f3986643f5fb94977ae33290b2e2f6872360db0ad6bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyproject_scripts-0.1.0-py3-none-any.whl:

Publisher: release.yml on okleinke/pyproject-scripts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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