CrumbleCracker Python Bindings
Python bindings for the CrumbleCracker virtualization library, providing a Pythonic interface to cc's virtualization primitives.
Installation
From PyPI (Recommended)
pip install crumblecracker
The PyPI package includes the native library (libcc.so/libcc.dylib) for supported platforms.
From Source
-
Build the
libccshared library:cd /path/to/cc ./tools/build.go -bindings-c
-
Set the library path (or copy
libcc.dylib/libcc.soto a standard location):export LIBCC_PATH=/path/to/cc/build/libcc.dylib
-
Install the package:
pip install -e /path/to/cc/bindings/python
Quick Start
import crumblecracker as cc
# Initialize the library
cc.init()
# Check for hypervisor support
if cc.supports_hypervisor():
print("Hypervisor available!")
else:
print("No hypervisor - some features may be limited")
# Query system capabilities
caps = cc.query_capabilities()
print(f"Architecture: {caps.architecture}")
# Pull an image and create an instance
with cc.OCIClient() as client:
# Pull with progress callback
def on_progress(p):
if p.total > 0:
pct = p.current * 100 // p.total
print(f"\rDownloading: {pct}%", end="")
source = client.pull("alpine:latest", progress_callback=on_progress)
print() # newline after progress
# Get image config
config = source.get_config()
print(f"Image architecture: {config.architecture}")
# Create and run instance
options = cc.InstanceOptions(memory_mb=512, cpus=2)
with cc.Instance(source, options) as inst:
print(f"Instance ID: {inst.id}")
# Run a command
output = inst.command("echo", "Hello from VM!").output()
print(output.decode())
# File operations
inst.write_file("/tmp/test.txt", b"Hello, World!")
data = inst.read_file("/tmp/test.txt")
print(f"Read: {data.decode()}")
# Directory operations
inst.mkdir("/tmp/mydir")
for entry in inst.read_dir("/tmp"):
print(f" {entry.name} (dir={entry.is_dir})")
# Cleanup
cc.shutdown()
API Reference
Module Functions
cc.init()- Initialize the library (required before any other call)cc.shutdown()- Shutdown and release resourcescc.api_version()- Get API version stringcc.api_version_compatible(major, minor)- Check version compatibilitycc.supports_hypervisor()- Check if hypervisor is availablecc.query_capabilities()- Get system capabilitiescc.guest_protocol_version()- Get guest protocol version
Classes
OCIClient
OCI image client for pulling and managing container images.
with cc.OCIClient(cache_dir=None) as client:
source = client.pull("alpine:latest", options=None, progress_callback=None)
source = client.load_tar("/path/to/image.tar")
source = client.load_dir("/path/to/extracted")
client.export_dir(source, "/path/to/output")
Instance
A running VM instance with filesystem, command, and network access.
with cc.Instance(source, options) as inst:
# Properties
inst.id # Instance ID
inst.is_running # Check if running
# Lifecycle
inst.wait() # Wait for termination
inst.close() # Close and cleanup
# Filesystem
inst.read_file(path)
inst.write_file(path, data, mode=0o644)
inst.stat(path)
inst.mkdir(path, mode=0o755)
inst.remove(path)
inst.read_dir(path)
# File handles
with inst.open(path) as f:
data = f.read()
with inst.create(path) as f:
f.write(data)
# Commands
output = inst.command("echo", "hello").output()
exit_code = inst.command("ls", "-la").run()
# Networking
listener = inst.listen("tcp", ":8080")
# Snapshots
snapshot = inst.snapshot_filesystem()
Cmd
Command builder for execution in instances.
cmd = inst.command("env")
cmd.set_dir("/tmp")
cmd.set_env("MY_VAR", "value")
# Synchronous execution
exit_code = cmd.run()
# Capture output
stdout = cmd.output()
combined = cmd.combined_output()
# Async execution
cmd.start()
# ... do other work ...
exit_code = cmd.wait()
# Streaming I/O with pipes
cmd = inst.command("cat")
stdin = cmd.stdin_pipe() # Returns Conn (writable)
stdout = cmd.stdout_pipe() # Returns Conn (readable)
stderr = cmd.stderr_pipe() # Returns Conn (readable)
cmd.start()
stdin.write(b"hello")
stdin.close() # Close to signal EOF
data = stdout.read(256) # Read output incrementally
stdout.close()
cmd.wait()
File
File handle for read/write operations.
with inst.open(path) as f:
data = f.read()
data = f.read(1024) # Read up to 1024 bytes
f.seek(0, cc.SeekWhence.SET)
info = f.stat()
with inst.create(path) as f:
f.write(b"data")
f.truncate(10)
f.sync()
Types
InstanceOptions- VM configuration (memory_mb, cpus, timeout_seconds, user, mounts)PullOptions- Image pull options (platform, auth, policy)PullPolicy- Pull policy enum (IF_NOT_PRESENT, ALWAYS, NEVER)FileInfo- File metadata (name, size, mode, is_dir, is_symlink)DirEntry- Directory entry (name, is_dir, mode)ImageConfig- OCI image configurationCapabilities- System capabilitiesSeekWhence- Seek origin (SET, CUR, END)
File Open Flags
cc.O_RDONLY # Read only
cc.O_WRONLY # Write only
cc.O_RDWR # Read and write
cc.O_APPEND # Append mode
cc.O_CREATE # Create if not exists
cc.O_TRUNC # Truncate to zero
cc.O_EXCL # Exclusive create
Exceptions
All exceptions inherit from cc.CCError:
InvalidHandleError- Handle is invalid or freedInvalidArgumentError- Invalid function argumentNotRunningError- Instance has terminatedAlreadyClosedError- Resource already closedTimeoutError- Operation timed outHypervisorUnavailableError- No hypervisor supportIOError- Filesystem I/O errorNetworkError- Network errorCancelledError- Operation was cancelled
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run tests (non-VM tests only)
pytest
# Run all tests including VM tests (requires hypervisor)
CC_RUN_VM_TESTS=1 pytest
License
MIT
Metadata
Release files for crumblecracker 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details |
| crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_aarch64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ ARM64 | Details |
| crumblecracker-0.0.3-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 45.0 MB
Release files / crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_x86_64.whl
| Download URL | crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 17.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7095c080a770bcc145b2bd950b2db394b6c73ec14e108d9ce3c295167dd0f8f9
|
|
BLAKE2b-256 checksum How to use checksums |
5990260797ee88da9b7fe19151c305ded5917cb1eef31a21578c8e038efe728f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Feb 13, 2026.
Transparency logRelease files / crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_aarch64.whl
| Download URL | crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 15.6 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
c763c686208c1ecca2d835a998c6b03feca1ab7eb1ed739664dcefdecf4d77e5
|
|
BLAKE2b-256 checksum How to use checksums |
e17b27fedb99875ffe032729e249f996a4190fa391f38176b74ef29a7b1404ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Feb 13, 2026.
Transparency logRelease files / crumblecracker-0.0.3-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | crumblecracker-0.0.3-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5e4b3c5d6e9e71669b1a8af27901feed950227f8878b0095e3582a9111cbb48d
|
|
BLAKE2b-256 checksum How to use checksums |
cfc0c14895d340f5df0b2fa3449f366f2c6ebf76f7b11f529d67f34fb1b87db2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Feb 13, 2026.
Transparency logSecurity for crumblecracker 0.0.3
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
All 3 files in this release have been uploaded with provenance metadata.
Attestation for crumblecracker-0.0.3-cp312-cp312-manylinux_2_17_x86_64.whl
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 Feb 13, 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.