Skip to main content

cuprum package

Project description

cuprum

Typed, async command execution for Python—so you can ditch the shell scripts without losing your mind.

What is this?

If you've ever written a Python script that calls out to external commands, you've probably experienced the joys of subprocess: stringly-typed arguments, mysterious failures, and output that vanishes into the void. Cuprum is here to help.

We give you a typed, safe approach to running external programs. Instead of passing arbitrary strings to a shell, you work with a curated catalogue of approved executables. Each command carries metadata about its project, so downstream tooling knows how to filter noise from logs or where to find documentation.

Cuprum is async-first but provides synchronous wrappers for scripts that don't need the full async machinery. Whether you're building deployment helpers, CI glue, or maintenance scripts, we want "Python instead of Bash" to feel like an upgrade rather than a chore.

Quick taste

from cuprum import ECHO, ExecutionContext, sh

# Create a builder for a curated program
echo = sh.make(ECHO)

# Build a command with typed arguments
cmd = echo("-n", "hello, cuprum!")

# Run it (async)
result = await cmd.run(echo=True)
if result.ok:
    print(f"Output: {result.stdout}")

# Or run it synchronously
result = cmd.run_sync()

Features

  • Catalogue-based safety – Only approved programs can run; unknown executables raise UnknownProgramError.
  • Typed command buildingsh.make() returns builders that validate arguments and carry project metadata.
  • Async-first executionawait cmd.run() with capture/echo toggles, environment overlays, and working directory control.
  • Synchronous conveniencecmd.run_sync() when you don't need async.
  • Graceful cancellation – Cancelled tasks send SIGTERM, wait briefly, then escalate to SIGKILL.
  • Structured resultsCommandResult gives you exit code, pid, stdout, stderr, and an ok helper.
  • Zero dependencies – Just Python 3.12+ and the standard library.

Installation

pip install cuprum

Or with uv:

uv add cuprum

Status

Cuprum is in early development. The typed command core and execution runtime are complete (Phase 1 of the roadmap), but context-scoped allowlists and hooks are still on the way. The API may shift as we learn what works best.

Documentation

For the full guide—including how to build your own program catalogues, write project-specific builders, and control execution contexts—see the users' guide.

Why "cuprum"?

The name is a tip of the hat to Plumbum, the library that showed us shell-like scripting in Python could actually be pleasant. "Cuprum" is Latin for copper—another metal used in pipes—and we hope to carry that spirit forward with a focus on type safety and explicit allowlists.

Licence

ISC

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

cuprum-0.1.0.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

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

cuprum-0.1.0-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

File details

Details for the file cuprum-0.1.0.tar.gz.

File metadata

  • Download URL: cuprum-0.1.0.tar.gz
  • Upload date:
  • Size: 47.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for cuprum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdc6ab92b1895613f7bfc35c762376f4830928add3d39061f7b3806d7aa422b4
MD5 5471b823853764b201a3c86a3a49d4f8
BLAKE2b-256 412a75534f4578a7437fab7d0075ea5955a1553bf4cf016ab0d9a6e5a24f6f7f

See more details on using hashes here.

File details

Details for the file cuprum-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cuprum-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 60.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for cuprum-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b03e813bb56afe75f6cc38ec742091a0b1dc183480630abbaf8f205c984c3e72
MD5 b891ce7dc1bc7153b1457d668b8d6d09
BLAKE2b-256 2f2ba5ada0f42e8e27c0ce8102256344db5adc339334293431319da06e33a80c

See more details on using hashes here.

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