ebtp for Python
Python client for ebtp: uploads files with content-defined chunking and
chunk-level dedup, and reads them back whole or by byte range over HTTP or HTTPS. The package
wraps the Rust client ebtp-client, so Python runs the same pipeline: file ids are the ids the
Rust client computes for the same bytes, and every downloaded chunk is checked against its hash.
Install
pip install ebtp
Wheels are abi3 and work on CPython 3.10 and newer (Linux x86_64 and aarch64, macOS arm64). Other platforms build from the source distribution, which needs a Rust toolchain.
Blocking client
import ebtp
client = ebtp.Client("http://127.0.0.1:8080")
id = client.put("model.safetensors")
ids = client.put_all(["a.bin", "b.bin"])
other = client.put_bytes(b"bytes already in memory")
size = client.len(id)
data = client.get(id)
client.get_into(id, "copy.safetensors")
files = client.get_all(ids)
Calls release the interpreter while they read, hash, compress and transfer, so threads can run uploads and downloads side by side.
Ctrl-C, or any signal handler that raises, stops a call on the main thread within about 0.1 s:
no new requests start, and once the exception is raised the call writes nothing more to its
target. Requests already sent, at most the pipeline's concurrency of them, finish in the
background. A write to the target that is running when the signal arrives is finished first, so
a target on a stalled file system or a FIFO nobody reads holds up the stop.
asyncio client
import asyncio
import ebtp
async def main() -> None:
client = ebtp.AsyncClient("http://127.0.0.1:8080")
id = await client.put("model.safetensors")
head = await client.get(id, 0, 1 << 20)
ids = await asyncio.gather(*(client.put(p) for p in ["a.bin", "b.bin"]))
asyncio.run(main())
Both clients take the same arguments and have the same methods; AsyncClient returns asyncio
futures that a Tokio runtime inside the extension drives. Cancelling one, for example through
asyncio.wait_for, starts no new requests, and the call writes nothing more to its target after
the awaiting task sees the cancellation; as with Ctrl-C, a write that is running is finished
first, on the event loop's thread. get_into calls the write method of a file object on the
event loop, so objects bound to the loop can be targets. If the loop stops running before such a
call is done, the call fails with FileError and writes nothing more.
Downloads waiting on the network hold no threads, so many of them can run at once from asyncio tasks or from threads.
Processes
A client works in a process forked after it was used, such as a multiprocessing or PyTorch
DataLoader worker: the child opens its own connections and runs its own Tokio runtime. The
child cannot free the parent's runtime and connections, so each forked child keeps a fixed
amount of the parent's memory and file descriptors, and the parent's connections stay open
until its children exit. Forking while a call runs on another thread is not supported; CPython
warns about forking a process with threads for the same reason.
Pipeline
The second argument is the pipeline spec, "v1" by default. Uploads with different pipelines
give different file ids for the same bytes; any pipeline reads any file.
client = ebtp.Client("http://127.0.0.1:8080", "v1,small_put=4M")
Credentials
A static bearer token, for example one from an OIDC provider:
client = ebtp.Client(url, credentials=ebtp.Token("eyJ..."))
An API key, traded at the server for tokens of one namespace and scope ("read" or "write").
Tokens are replaced shortly before they expire, and a token the server refuses is replaced once:
client = ebtp.Client(url, credentials=ebtp.ApiKey(key, "team-a", "write"))
HTTPS with a custom root
HTTPS verifies servers against the Mozilla root store bundled with the client (webpki-roots), not the operating system's store. To also trust a private CA, pass its PEM certificate:
from pathlib import Path
client = ebtp.Client(
"https://ebtp.internal:8443",
root_certificate=Path("ca.pem").read_text(),
)
Timeout
timeout (seconds) bounds connecting and each read of a response; a transfer that keeps making
progress is not cut off.
client = ebtp.Client(url, timeout=30)
Range reads
get(id, start, end) returns bytes [start, end); end defaults to the file length.
get_into(id, target, start, end) writes them to a path or to a writable binary file object
and returns the byte count. A path is created or truncated only once the server has confirmed
the range; a read that fails after that, for example on a hash mismatch or a dropped
connection, leaves the file truncated or partly written. ebtp.Target, ebtp.StrPath and
ebtp.BinaryWriter name the accepted types.
import io
size = client.len(id)
tail = client.get(id, max(size - 4096, 0))
buffer = io.BytesIO()
client.get_into(id, buffer, 0, 1 << 20)
Errors
Every error is an ebtp.EbtpError. Branch on its subclasses:
| Class | When |
|---|---|
NotFound |
no file has this id |
Unauthorized |
credentials missing, refused, or not allowed to do this |
InvalidRange |
the range ends past the end of the file, starts after its end or is negative |
IntegrityError |
a downloaded chunk does not match its hash or does not decode |
TransportError |
the server could not be reached, or a request or transfer failed or timed out |
ServerError |
the server answered with an unexpected status or body |
ConfigError |
invalid URL, pipeline, certificate, credentials or timeout |
FileError |
a local file could not be read or written, or changed during upload |
An exception raised by a file object passed to get_into propagates unchanged. A buffer the
interpreter cannot allocate raises MemoryError.
InvalidRange carries start, end and len (the file length) when the server reported them,
and None otherwise:
try:
data = client.get(id, 0, 1 << 30)
except ebtp.InvalidRange as error:
data = client.get(id, 0, error.len)
License
MIT OR Apache-2.0, at your option.
Metadata
Release files for ebtp 0.4.0
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 |
|---|---|---|---|---|
| ebtp-0.4.0.tar.gz | 169.4 kB | With provenance | Details for ebtp-0.4.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ebtp-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for ebtp-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl |
| ebtp-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details for ebtp-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl |
| ebtp-0.4.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for ebtp-0.4.0-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 11.2 MB
Release files / ebtp-0.4.0.tar.gz
| Download URL | ebtp-0.4.0.tar.gz |
|---|---|
| Size | 169.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60e74e3102fd9a10d1ca8974e6bf9bb5ab6cbb05ba0ff89ed406b9043e979da3
|
|
BLAKE2b-256 checksum How to use checksums |
d23124225e59b113edd88a82e8fcf56b235af1fad0208f781a3421a6283ce110
|
| 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 28, 2026.
Transparency logRelease files / ebtp-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | ebtp-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7fdc3985f5c37424b8dc3dfab39e91d907b0be9d533c87421add9d58cc08fa12
|
|
BLAKE2b-256 checksum How to use checksums |
6dfc80d58c78581b4eabe9e58190d17425169e026321f0b9110a92570d12b341
|
| 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 28, 2026.
Transparency logRelease files / ebtp-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | ebtp-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
840e77d834c56c36070fd69afe61edc63af6e5e993ebcb925ab0f22719150839
|
|
BLAKE2b-256 checksum How to use checksums |
2d933e04f2c24ed3548009ca931f81270e3f1214c7d09e59968c4d2c9a5ad5d2
|
| 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 28, 2026.
Transparency logRelease files / ebtp-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | ebtp-0.4.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
29b999e654e1037fc9a8c5a5c5c26a1647032377b3507ff7d27d5e376ec49679
|
|
BLAKE2b-256 checksum How to use checksums |
5363706b08bc144bad429c7557c8873a2be060a8a36a0c611c20b42e1f067dd1
|
| 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 28, 2026.
Transparency logSecurity for ebtp 0.4.0
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 4 files in this release have been uploaded with provenance metadata.
Attestation for ebtp-0.4.0.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 28, 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.