Skip to main content

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

Metadata

Release files for clonetree 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for clonetree 1.4.1
File Actions
clonetree-1.4.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for clonetree-1.4.1-py3-none-musllinux_1_2_x86_64.whl
clonetree-1.4.1-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for clonetree-1.4.1-py3-none-musllinux_1_2_aarch64.whl
clonetree-1.4.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for clonetree-1.4.1-py3-none-manylinux_2_28_x86_64.whl
clonetree-1.4.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for clonetree-1.4.1-py3-none-manylinux_2_28_aarch64.whl
clonetree-1.4.1-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for clonetree-1.4.1-py3-none-macosx_13_0_x86_64.whl
clonetree-1.4.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for clonetree-1.4.1-py3-none-macosx_13_0_arm64.whl
clonetree-1.4.1-py3-none-any.whl Python 3 none any Details for clonetree-1.4.1-py3-none-any.whl

Total release size: 800.8 kB

Release files / clonetree-1.4.1-py3-none-musllinux_1_2_x86_64.whl

Download URL clonetree-1.4.1-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
89b217918b36c25601136e544894021474c4ee26e1ea2d632785f02e27f7eb01
BLAKE2b-256 checksum
How to use checksums
83898920926824ca897dea367b8cd7fc977606f6989603ea64e7efb7110bfba7
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.1-py3-none-musllinux_1_2_aarch64.whl

Download URL clonetree-1.4.1-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
80628119f9d1b4c30718d2d8ddc58113ec5dd068e6e2e03149ead555cfd6c590
BLAKE2b-256 checksum
How to use checksums
e77f736f9c5844059fc5652ef244cef0e222c4afd6aaa507592e37a650151f30
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.1-py3-none-manylinux_2_28_x86_64.whl

Download URL clonetree-1.4.1-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
44fcb496cefe9154d62cec85b60b81f2c4c8eb4b50874a5675d03db64813f28d
BLAKE2b-256 checksum
How to use checksums
d8ebf1aa9a372c824c947e42858e94830262018b36b3b2438e63a7768376e947
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.1-py3-none-manylinux_2_28_aarch64.whl

Download URL clonetree-1.4.1-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
6957017b4d6cbb8b7f1f202044bebc5ce87c5b8e8b54e54b1353ac607dc14806
BLAKE2b-256 checksum
How to use checksums
f563aba74cf4f9ff0e5634bd807d46b36e01747eb8f435873b30b65d31f21db4
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.1-py3-none-macosx_13_0_x86_64.whl

Download URL clonetree-1.4.1-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
082c5f7b7e4b37f9493c9dc0d3490a65f7aeb6843dfcb8d7c4b579a79fbf1478
BLAKE2b-256 checksum
How to use checksums
b3752f23db09aa53d6f13de0993e5be57daa79eaf813980feb3fd354dcdcb794
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.1-py3-none-macosx_13_0_arm64.whl

Download URL clonetree-1.4.1-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
0881013f976af957d3ff1095a86791e58bf57c6a66051f8cd3ed1dd2b61f6174
BLAKE2b-256 checksum
How to use checksums
ff36065637b1a565d2e0c603b7d1810ef5d328d83af7a188668b0e68cf23ec56
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.1-py3-none-any.whl

Download URL clonetree-1.4.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e53a51a76faa66c94c762994a5bb1e0ab8f0bbcd9fd61abccdbfb372dbd2cd5a
BLAKE2b-256 checksum
How to use checksums
fee0f72fc87a8dd8b8bd73f1911a1d057542391eafc2ec581ef2786370afa5b2
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.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page