clonetree
Copy-on-write snapshots of a project directory, on macOS (APFS) and Linux (XFS and Btrfs). A snapshot is a full working copy that shares the project's data on disk, so it's fast to make, and takes no new space until files change.
It's the library behind the clonetree
CLI, and makes the same snapshots as clonetree new. The snapshot feature of
a project is the directory clonetree/feature.clonetree inside it. To clone a
single file or directory, see clonefile.
pip install clonetree
import clonetree
# Snapshot the current directory into clonetree/feature.clonetree.
created = clonetree.new(".", "feature")
# List, measure and delete snapshots.
snapshots = clonetree.list(".")
infos = clonetree.info(".")
clonetree.delete(".", "feature")
| Function | What it does | CLI command |
|---|---|---|
new |
Clones the project, except other snapshots, into a new snapshot. If it fails or you cancel it, it removes the partial snapshot. | clonetree new |
list |
Returns the snapshots. It doesn't read them, so it's instant. | clonetree ls |
info |
Measures each snapshot: the size of its files, and the disk space that only it uses. | clonetree info |
delete |
Removes a snapshot. If it stops partway, deleting it again removes the rest. | clonetree delete |
None of them follow symlinks out of a project or a snapshot. They return
dataclasses, such as Created and SnapshotInfo.
Progress and canceling
new, info and delete use several threads, and let other Python threads
run meanwhile. They take a progress callback, which runs on your thread about
20 times a second and once more at the end, and a Cancel, which you can call
from any thread:
cancel = clonetree.Cancel() # cancel.cancel() stops it.
clonetree.new(
".",
"feature",
progress=lambda p: print(f"{p.cloned} of {p.total} entries cloned"),
cancel=cancel,
)
Canceling makes the function raise clonetree.Error with code "Canceled",
after new has removed the partial snapshot. If progress raises, the
function stops the same way, and raises that. Ctrl-C stops them too, though
new only notices it when it has a progress callback.
Errors
The functions raise clonetree.Error, an OSError whose code says why,
such as "InvalidId" or "NoSpaceLeft". Its filename is the path that
failed, if there is one, and left_behind says whether part of a snapshot
remains. Its errno is the closest errno, where there is one. The type hints
list every code.
try:
clonetree.new(".", "feature")
except clonetree.Error as err:
if err.code != "PathAlreadyExists":
raise
print("feature already exists")
Requirements
- macOS with APFS, or Linux with XFS (with reflinks) or Btrfs. Snapshots must be on the project's filesystem.
- x86_64 or arm64. On Linux, glibc 2.28 or later, or musl.
- Python 3.11 or later.
pip installs the wheel for your platform, which includes the compiled library,
so it needs no build tools, and the package has no dependencies. On other
platforms, the functions raise clonetree.Error with code
"OperationUnsupported".
Documentation
- The docstrings document every function, dataclass and error.
- The library from Go, Zig, Rust and Node
Metadata
Release files for clonetree 1.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 800.8 kB
Release files / clonetree-1.4.2-py3-none-musllinux_1_2_x86_64.whl
| Download URL | clonetree-1.4.2-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 151.8 kB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
8cd2443b594c4c0813d9303c8ae9fc4ecbca73d77f3aeb8c85a2c8e918145f5c
|
|
BLAKE2b-256 checksum How to use checksums |
b71977ac22f4370dbc664bc98294576fce782873bf71e56eb82d51c9e240a13d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-musllinux_1_2_aarch64.whl
| Download URL | clonetree-1.4.2-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 134.4 kB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
6378de91da907145afb7853b5c3f26cc725dadcaff1533fd9d4a6aa7f347c9e0
|
|
BLAKE2b-256 checksum How to use checksums |
9cdc5e7c931fda4edbb70ef07c7d2a5dfbdf2e8bf92ab3b431363c7b16e0f8e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-manylinux_2_28_x86_64.whl
| Download URL | clonetree-1.4.2-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 138.6 kB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
01897a8ec8fbf564ccf88af80cdaefae167bcfd8d24ef17d5888176af6d7473b
|
|
BLAKE2b-256 checksum How to use checksums |
0c81cdffdea1e0b1a4d4b17057ba40694ef79cf4fc7165d7476930d6f55aff39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-manylinux_2_28_aarch64.whl
| Download URL | clonetree-1.4.2-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 121.1 kB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
7803f4490d21f9b9b66b2c8f81bf85acc976718d6eccd179a7c7d10116756df5
|
|
BLAKE2b-256 checksum How to use checksums |
8a23f14c1ae386a83d54316b7e7e4c881e24b05c2af75b8148c07e5ae822ce58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-macosx_13_0_x86_64.whl
| Download URL | clonetree-1.4.2-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 132.2 kB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
b7da7da245fb3251fc1c95f43448be1b7a239a9e9062bdbe97cae4717cbab2bf
|
|
BLAKE2b-256 checksum How to use checksums |
c3e8f19e0ab7f753de1c0ee4b05ce00af15a1eb1f69ce6bbe0cec7b951f83d7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-macosx_13_0_arm64.whl
| Download URL | clonetree-1.4.2-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 113.9 kB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ca0ff01746947af8fc533ba3067dfe55b85ea7fbc086c88fb0972d4c3b81a226
|
|
BLAKE2b-256 checksum How to use checksums |
6a7c7a3df7347d3ec089168afb970d0258b3f30328d2ec394fd1c2cb3cc863f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / clonetree-1.4.2-py3-none-any.whl
| Download URL | clonetree-1.4.2-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49b9c6921bc80b91ef49837bda0214e4eafd07388ec9a18289159bc14b0e585d
|
|
BLAKE2b-256 checksum How to use checksums |
95dba0035c1959b3ab688720f03271c59f98a68c15aad3ef5001487144ed9cfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for clonetree 1.4.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.