Simplify the use of Bash/Shell commands in Python
Project description
Py Bash Wrapper
Description
Py Bash Wrapper helps Python developers run bash/shell/subprocess commands with two convenience functions:
- The
run_commandfunction provides no advances shell features likes pipes. This function takes in either a string or an argv list. - The
run_bashfunction provides real Bash (e.g., pipes, redirects, globs, etc.). This function takes in a string.
Results come back as CommandResult with stdout, stderr, exit code, and an ok flag;
The argument check=True will cause failures to raise a CommandError.
Installation
From PyPI:
pip install py_bash_wrapper
Documentation
- Usage examples -- safe patterns,
run_commandvs.run_bash, errors and post-checks. - Project structure -- where code, tests, and automation live.
- Code style -- Ruff, Mypy, pytest, and conventions.
- Maintainers -- versions, CI, releases, security notes for shell APIs.
- Plan / roadmap -- upcoming tasks.
Full API details live in docstrings under py_bash_wrapper/bash_utils.py and in the usage doc above.
Security note
run_bash executes shell code. Do not pass untrusted input as the Bash command string. Prefer run_command
with a fixed argv when shell features are not required. See docs/usage_examples.md.
Quick start
Prerequisites: Initial setup (uv, make, and a supported version of Python3).
make install
from py_bash_wrapper.bash_utils import run_command, run_bash
print(run_command(["python", "-c", "print(1+1)"], check=True).stdout.strip())
print(run_bash("echo hello | wc -c", check=True).stdout.strip())
make run-tests
Initial setup
Prerequisites:
- uv (package and tool runner):
- macOS:
brew install uv(see Homebrew if needed). - Other: Installing uv (official installer and package managers).
- macOS:
- make:
- macOS: Xcode Command Line Tools or a build toolchain that provides
make. - Linux: install
build-essential. - Windows: use Git Bash, WSL, or another environment that provides
make, or run the sameuv run ...commands from the Makefile by hand.
- macOS: Xcode Command Line Tools or a build toolchain that provides
- Python 3.12+: install via OS package manager, via
uvwithuv python install 3.12, or via python.org.
Common operations
- Install dependencies and pre-commit hooks:
make install - Run tests (coverage HTML):
make run-tests - Run tests (terminal coverage summary):
make run-tests-terminal - Lint and format check:
make lint - Lint with auto-fix and format write:
make lint-fix - Pre-commit gate (Ruff + pytest):
make pre-commit - Build sdist and wheel:
make build - Print version from
VERSION:make version-show - After a
v*tag onHEAD, verify it matchesVERSION:make version-check-tag
Versioning
Releases follow SemVer.
The canonical version string is the repo-root VERSION file (which contains no v prefix).
Git tags use a v prefix (e.g., v0.2.0). Packaging reads VERSION via pyproject.toml dynamic metadata.
To cut a release: bump VERSION on a branch, open a PR, and merge to main.
When VERSION changes on main, the Tag and release from VERSION workflow
(.github/workflows/release-from-version.yml) creates an annotated tag vX.Y.Z on that commit. Then, if that tag does
not already exist on the remote, and if no GitHub Release already exists for that same tag, then the workflow pushes it.
The same workflow then verifies tag/version consistency, builds the wheel and sdist artifacts, publishes a GitHub
Release immediately with auto-generated notes, and uploads the same artifacts to PyPI (Trusted Publishing; GitHub
environment pypi). Configure the publisher in PyPI before the first upload; see docs/maintainers.md.
After a tag exists (or locally before pushing), make version-check-tag can be run to confirm the current v* tag
matches VERSION. CI runs scripts/verify_version_matches_tag.py on tag pushes for the same check.
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
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 py_bash_wrapper-0.3.3.tar.gz.
File metadata
- Download URL: py_bash_wrapper-0.3.3.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcbd4243c7e9ca728f6a7a50cdc897f87cd3fb850c34cc97798272a8eabf5a2c
|
|
| MD5 |
5bb2d6958371d0f0f81940af5d858567
|
|
| BLAKE2b-256 |
d5977e5daf580f3334583a5c16ce9b60e69828373a415b70c84dede189f1d496
|
Provenance
The following attestation bundles were made for py_bash_wrapper-0.3.3.tar.gz:
Publisher:
release-from-version.yml on themarkrogers/py_bash_wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_bash_wrapper-0.3.3.tar.gz -
Subject digest:
fcbd4243c7e9ca728f6a7a50cdc897f87cd3fb850c34cc97798272a8eabf5a2c - Sigstore transparency entry: 1273027721
- Sigstore integration time:
-
Permalink:
themarkrogers/py_bash_wrapper@57b4e5268926f8a78d7fde2ce9a0947c5aaf9668 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/themarkrogers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-from-version.yml@57b4e5268926f8a78d7fde2ce9a0947c5aaf9668 -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_bash_wrapper-0.3.3-py3-none-any.whl.
File metadata
- Download URL: py_bash_wrapper-0.3.3-py3-none-any.whl
- Upload date:
- Size: 20.0 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 |
72c7f51c1fef37b5bd0c5e9830e245a35e5aa52cafba5debfde6e3d33fe304bc
|
|
| MD5 |
55ee03cfb8c3f7e7ead2923e1711a2c6
|
|
| BLAKE2b-256 |
451ff250b7ca85c8289f28a3f77ce225cd36bbdf7a55ea75b43d44eaa428272c
|
Provenance
The following attestation bundles were made for py_bash_wrapper-0.3.3-py3-none-any.whl:
Publisher:
release-from-version.yml on themarkrogers/py_bash_wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_bash_wrapper-0.3.3-py3-none-any.whl -
Subject digest:
72c7f51c1fef37b5bd0c5e9830e245a35e5aa52cafba5debfde6e3d33fe304bc - Sigstore transparency entry: 1273027747
- Sigstore integration time:
-
Permalink:
themarkrogers/py_bash_wrapper@57b4e5268926f8a78d7fde2ce9a0947c5aaf9668 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/themarkrogers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-from-version.yml@57b4e5268926f8a78d7fde2ce9a0947c5aaf9668 -
Trigger Event:
push
-
Statement type: