Development Status
- 5 - Production/Stable
Environment
- Console
Intended Audience
- Developers
- System Administrators
License
- OSI Approved :: MIT License
Programming Language
- Python
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Topic
- Software Development :: Build Tools
- Software Development :: Libraries :: Python Modules
sh is a full-fledged subprocess replacement for Python 3.10 - 3.14, and PyPy that allows you to call any program as if it were a function:
from sh import git
print(git("status", "--short"))
sh is not a collection of system commands implemented in Python.
sh relies on various Unix system calls and only works on Unix-like operating systems - Linux, macOS, BSDs etc. Specifically, Windows is not supported.
Full documentation on a single page for LLM-assisted coding here
Installation
$> pip install sh
Support
Andrew Moffat - author/maintainer
Developers
Open the repo in a devcontainer in VScode, or in a codespace on Github.
Testing
Tests are run by tox against all supported Python versions. To run, make the following target:
$> make test
To run a single test:
$> make test='FunctionalTests.test_background' test_one
Docs
To build the docs, make sure you’ve run poetry install to install the dev dependencies, then:
$> cd docs $> make html
This will generate the docs in docs/build/html. You can open the index.html file in your browser to view the docs.
Coverage
First run all of the tests:
$> SH_TESTS_RUNNING=1 coverage run --source=sh -m pytest
This will aggregate a .coverage. You may then visualize the report with:
$> coverage report
Or generate visual html files with:
$> coverage html
Which will create ./htmlcov/index.html that you may open in a web browser.