Poetry application plugin that runs declarative shell actions before `poetry run <name>` based on the active environment.
Project description
Poetry Run Actions Plugin
A Poetry plugin that runs declarative shell actions immediately
before poetry run <name>, gated by the active environment.
Use it to attach side effects (e.g. docker compose up -d redis) to a package
or script without baking them into the entry point itself, so the same
pyproject.toml can be deployed in production without firing dev-only setup.
Install
Install via Poetry:
poetry self add poetry-run-actions
To uninstall:
poetry self remove poetry-run-actions
Configure
Actions attach to a package declared in [tool.poetry] packages or a
script declared in [project.scripts] / [tool.poetry.scripts].
Configure them under separate subtables:
[tool.poetry]
packages = [{include = "api"}, {include = "worker"}]
[project.scripts]
migrate = "myapp.db:migrate"
# Package target: fires on `poetry run python -m api` because `api` is in [tool.poetry] packages
[tool.poetry-run-actions.dev.packages.api]
setup-commands = ["docker compose up -d redis"]
pre-start-commands = ["echo 'starting api'"]
# Script target: fires on `poetry run migrate` because `migrate` is in [project.scripts]
[tool.poetry-run-actions.dev.scripts.migrate]
pre-start-commands = "echo 'about to migrate'"
Each entry under packages.<name> or scripts.<name> can take one of three
shapes:
# 1. Shorthand: a single shell command (treated as `pre-start-commands`)
[tool.poetry-run-actions.dev.packages]
worker = "docker compose up -d postgres"
# 2. Shorthand: a list of shell commands (treated as `pre-start-commands`)
[tool.poetry-run-actions.dev.packages]
cli = ["docker compose up -d redis", "docker compose up -d postgres"]
# 3. Full form: a table with `setup-commands` and/or `pre-start-commands`
[tool.poetry-run-actions.dev.packages.api]
setup-commands = ["docker compose up -d redis"]
pre-start-commands = ["echo 'starting api'"]
setup-commands vs. pre-start-commands
Both are optional and accept either a single string or a list of strings.
On every matching poetry run python -m <name> (for packages) or
poetry run <name> (for scripts) invocation, the plugin runs:
Setup commands should be idempotent and run before the pre-start commands. This can be used to install dependencies. Pre-start commands are for application dependencies, such as Redis.
Environment Selection
The active environment is read from POETRY_ENVIRONMENT, defaulting to dev.
Example:
POETRY_ENVIRONMENT |
Behavior |
|---|---|
| unset (default) | Looks up tool.poetry-run-actions.dev.{packages,scripts}.<name> |
dev |
Same as default |
production |
Looks up tool.poetry-run-actions.production.{packages,scripts}.<name> |
| any other value | Looks up tool.poetry-run-actions.<value>.{packages,scripts}.<name> |
Run Tests
Install development dependencies:
poetry install -E dev
Run tests:
poetry run pytest .
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 poetry_run_actions-0.0.2.tar.gz.
File metadata
- Download URL: poetry_run_actions-0.0.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a90cf3d58888c55f29a5e7a8824b6a9c5bd4d670928891193f46fa550ee65e56
|
|
| MD5 |
6556420688ee14f3866d913ace38cce8
|
|
| BLAKE2b-256 |
7f5de27dc1108daf8151df1439d36f09579d522c8fa1a78136741532d2a1bbc9
|
Provenance
The following attestation bundles were made for poetry_run_actions-0.0.2.tar.gz:
Publisher:
publish-to-pypi.yml on julien777z/poetry-run-actions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
poetry_run_actions-0.0.2.tar.gz -
Subject digest:
a90cf3d58888c55f29a5e7a8824b6a9c5bd4d670928891193f46fa550ee65e56 - Sigstore transparency entry: 1436337615
- Sigstore integration time:
-
Permalink:
julien777z/poetry-run-actions@1132ebe1a074406c54901f9dea1e40803b404bb6 -
Branch / Tag:
refs/heads/claude/fix-redis-docker-startup-z0SWN - Owner: https://github.com/julien777z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1132ebe1a074406c54901f9dea1e40803b404bb6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file poetry_run_actions-0.0.2-py3-none-any.whl.
File metadata
- Download URL: poetry_run_actions-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bb08c14a54b5a1f3a7b7a438249e6f4904abf0c19f1a48e2b4606d3af42a1a9
|
|
| MD5 |
b23610ce554b0447b00f9dd4efe5b0fb
|
|
| BLAKE2b-256 |
465f0cfb531466f2b1b7b97816a85cd10325209a847aa9f7323eddbdbd7800ef
|
Provenance
The following attestation bundles were made for poetry_run_actions-0.0.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on julien777z/poetry-run-actions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
poetry_run_actions-0.0.2-py3-none-any.whl -
Subject digest:
7bb08c14a54b5a1f3a7b7a438249e6f4904abf0c19f1a48e2b4606d3af42a1a9 - Sigstore transparency entry: 1436337648
- Sigstore integration time:
-
Permalink:
julien777z/poetry-run-actions@1132ebe1a074406c54901f9dea1e40803b404bb6 -
Branch / Tag:
refs/heads/claude/fix-redis-docker-startup-z0SWN - Owner: https://github.com/julien777z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1132ebe1a074406c54901f9dea1e40803b404bb6 -
Trigger Event:
workflow_dispatch
-
Statement type: