Skip to main content

Python subprocess replacement

Project description

Logo Version Downloads Status Python Versions Coverage Status

sh is a full-fledged subprocess replacement for Python 3.8 - 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.

Complete documentation here

Full documentation on a single page for LLM-assisted coding here

Installation

$> pip install sh

Support

Developers

Testing

Tests are run in a docker container 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.

Download files

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

Source Distribution

sh-2.2.6.tar.gz (132.3 kB view details)

Uploaded Source

Built Distribution

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

sh-2.2.6-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file sh-2.2.6.tar.gz.

File metadata

  • Download URL: sh-2.2.6.tar.gz
  • Upload date:
  • Size: 132.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sh-2.2.6.tar.gz
Algorithm Hash digest
SHA256 0cb3fac1a202a213b843d0fb9fa713da2444d4fc2e75d4ae83cd96e2a2095465
MD5 a072542960aaa73b060c1806fb9432cc
BLAKE2b-256 cf204601f39e47d84c281a2d66c15e0052a4a2b2256b46116758a5baee72ea8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sh-2.2.6.tar.gz:

Publisher: main.yml on amoffat/sh

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

File details

Details for the file sh-2.2.6-py3-none-any.whl.

File metadata

  • Download URL: sh-2.2.6-py3-none-any.whl
  • Upload date:
  • Size: 43.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sh-2.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c52c32b58009472251c2384c364b7388fc369f082fb61b045b76aed2e2942b2d
MD5 b546008dd49026d578ba821b5b803f4f
BLAKE2b-256 8cd7e3a4841db3ed31ee1fccc0bae2da79b9f46441395a3904028425f6c4059b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sh-2.2.6-py3-none-any.whl:

Publisher: main.yml on amoffat/sh

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