Proclet
Proclet is a fluent, typed wrapper around Python's subprocess, with matching sync and async APIs, binary-safe pipelines, privilege dropping and low-priority execution.
🚀 Quick start
Requires Python 3.12 or newer, on Linux, macOS or Windows. No runtime dependency.
pip install proclet
Or with another package manager:
uv add proclet
poetry add proclet
pdm add proclet
pipenv install proclet
import asyncio
from io import StringIO
from proclet import Command
# Run a command and capture its output.
out = StringIO()
Command("git").args("rev-parse", "HEAD").stdout(out).timeout(10).exec()
print(out.getvalue().strip())
# Chain commands through raw OS pipes, no shell involved.
Command("git").args("log", "--format=%an").pipe(
Command("sort").args("-u").inherit_out()
)
# Run the same configuration with asyncio.
asyncio.run(Command("git").args("fetch", "--all").inherit_out().aexec())
- A failing command raises
ErrorReturnCode, a missing binaryCommandNotFoundand an elapsed timeoutTimeoutException. - The usage section covers each feature in detail; the documentation site adds recipes, migration guides and the API reference.
✨ Features
- Fluent and typed: configure a command through a chainable API, checked by your type checker.
- Sync and async: run the same
Commandwithexec()orawait aexec(). - Output anywhere: redirect to files, file objects,
StringIO/BytesIOor a callable receiving each line. - Input from anywhere: feed stdin from a string, bytes, a file object or a queue.
- Shell-free pipelines: chain commands through raw OS pipes, safe for binary payloads.
- Guard rails: enforce timeouts and choose the exit codes that count as success.
- Environment control: build a command's environment and
PATHfrom the current ones. - Privilege dropping: run as another user, group and set of supplementary groups.
- Low priority: lower the CPU (and, on Linux, IO) priority of a command, Windows included.
- Typed wrappers: turn a binary into a Python API of its own with
Bind. - Observability: get notified of every process spawn and exit.
🎯 Motivation
- We needed a way to run external tools from Python code without repeating
subprocessboilerplate. - Redirecting output to a logger, feeding stdin from a queue or chaining binary-safe pipelines shouldn't require hand-written threads.
- The same API should serve sync and
asynciocode. - The library should stay framework-agnostic: no runtime dependencies, no logging setup, failures are exceptions the caller decides about.
Streaming a database dump through a compressor, logging both tools' stderr line by line, with a timeout and an exit code check, looks like this with subprocess:
import logging
import subprocess
import threading
log = logging.getLogger(__name__)
dump = subprocess.Popen(
["pg_dump", "shop"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
pack = subprocess.Popen(
["zstd", "-q", "-o", "shop.sql.zst"], stdin=dump.stdout, stderr=subprocess.PIPE
)
dump.stdout.close() # let pg_dump see a broken pipe if zstd dies
def forward(stream):
for line in stream:
log.warning(line.decode().rstrip("\n"))
threads = [threading.Thread(target=forward, args=(p.stderr,)) for p in (dump, pack)]
for thread in threads:
thread.start()
try:
dump.wait(timeout=600)
pack.wait(timeout=600)
finally:
for process in (dump, pack):
if process.poll() is None:
process.kill()
for thread in threads:
thread.join()
for process in (dump, pack):
if process.returncode != 0:
raise RuntimeError(f"{process.args} exited with {process.returncode}")
With proclet:
import logging
from proclet import Command, strip_redirect
log = logging.getLogger(__name__)
to_log = strip_redirect(log.warning)
Command("pg_dump").args("shop").stderr(to_log).timeout(600).pipe(
Command("zstd").args("-q", "-o", "shop.sql.zst").stderr(to_log).timeout(600)
)
Compared to other libraries
subprocess |
sh |
plumbum |
invoke |
proclet |
|
|---|---|---|---|---|---|
| Style | function arguments | commands as functions | local["git"] objects and operators |
shell command strings | chainable builder |
| Windows | yes | no | yes | yes | yes |
| asyncio | separate API | _async=True |
separate async commands | no | same Command (aexec()) |
| Pipelines without a shell | hand-wired Popens |
yes | yes | no | yes, raw OS pipes |
| Run as another user | user= |
_uid= |
no | no | user() |
| Choose the group and supplementary groups | group=, extra_groups= |
no | no | no | group(), extra_groups() |
| Lower the priority | by hand (preexec_fn) |
no | no | no | nice(), Windows included |
- Checked against
sh2.4,plumbum2.0 andinvoke3.0.invokeis mainly a task runner andplumbumalso covers CLI apps and remote machines: pick them for that. - Spotted a mistake? Please open an issue.
📖 Usage
The documentation site covers every feature with examples:
- How to run a command
- How to handle failures
- How to capture and stream output
- How to feed stdin
- How to run a command in the background
- How to run commands with asyncio
- How to chain commands into a pipeline
- How to set the environment and PATH
- How to drop privileges and lower priority
- How to reuse a configuration
- How to wrap a binary into a typed API
- How to observe processes
It also has recipes for common problems (streaming output to a logger,
timeouts, binary pipes, running as another user, concurrency with asyncio, wrapping a CLI),
migration guides from sh and
from plumbum, and the API reference.
❤️ Contributing
If you find this project useful here's how you can help, please click the 👁️ Watch button to avoid missing notifications about new versions, and give it a 🌟 GitHub Star!
You can also contribute by:
- Sending a Pull Request with your awesome new features and bug fixed.
- Be part of the community and help resolve Issues.
Read CONTRIBUTING.md to set up the project and check your changes before opening a pull request.
🧾 License
The proclet project is free and open-source software licensed under the Apache-2.0 license.
Metadata
Release files for proclet 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| proclet-0.1.2.tar.gz | 28.2 kB | With provenance | Details for proclet-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| proclet-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for proclet-0.1.2-py3-none-any.whl |
Total release size: 56.3 kB
Release files / proclet-0.1.2.tar.gz
| Download URL | proclet-0.1.2.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ec51d8ecf0c54d0048d9c2b95e4363cd52e1a0e978e21acbc316c6993f9e2b4
|
|
BLAKE2b-256 checksum How to use checksums |
1e942aadbd62d3c65e3d3e88dd20880c13a2db2feb59002de5b04aee8053d3e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / proclet-0.1.2-py3-none-any.whl
| Download URL | proclet-0.1.2-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aae65a027b2ab8f0999eb5987dc91e2af229739a8a105ea8c33a6ca3c6c523cd
|
|
BLAKE2b-256 checksum How to use checksums |
50f2079d2ee78d49e7f661a0e6737730e61c41f1f5b73bde48799c9aeea0fa09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for proclet 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for proclet-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.