Skip to main content

clonefile

Copy-on-write clones of files and directories, on macOS (APFS) and Linux (XFS and Btrfs). A clone shares the original's data on disk, so it's fast to make, and takes no new space until either copy changes.

It's the library behind the clonetree CLI's clones. For whole-project snapshots, see clonetree.

pip install clonefile
import clonefile

# Clone a file, or a directory with everything in it.
clonefile.clone("src", "src-copy")
  • It never copies data. If the filesystem can't clone, it raises.
  • It never replaces anything. The destination must not exist, but its parent must.
  • If it fails partway, it removes what it created.
  • Other Python threads keep running while it clones.

Errors

clone raises clonefile.Error, an OSError whose code says why, such as "PathAlreadyExists" or "OperationUnsupported". Its errno is the closest errno, such as errno.EEXIST, where there is one. The type hints list every code.

try:
    clonefile.clone("src", "src-copy")
except clonefile.Error as err:
    if err.code != "PathAlreadyExists":
        raise
    print("src-copy is already there")

Requirements

  • macOS with APFS, or Linux with XFS (with reflinks) or Btrfs. The source and the clone must be on the same 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, clone raises clonefile.Error with code "OperationUnsupported".

Documentation

Metadata

Release files for clonefile 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 clonefile 1.4.1
File Actions
clonefile-1.4.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for clonefile-1.4.1-py3-none-musllinux_1_2_x86_64.whl
clonefile-1.4.1-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for clonefile-1.4.1-py3-none-musllinux_1_2_aarch64.whl
clonefile-1.4.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for clonefile-1.4.1-py3-none-manylinux_2_28_x86_64.whl
clonefile-1.4.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for clonefile-1.4.1-py3-none-manylinux_2_28_aarch64.whl
clonefile-1.4.1-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for clonefile-1.4.1-py3-none-macosx_13_0_x86_64.whl
clonefile-1.4.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for clonefile-1.4.1-py3-none-macosx_13_0_arm64.whl
clonefile-1.4.1-py3-none-any.whl Python 3 none any Details for clonefile-1.4.1-py3-none-any.whl

Total release size: 567.8 kB

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

Download URL clonefile-1.4.1-py3-none-musllinux_1_2_x86_64.whl
Size 113.8 kB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
43bf5d694734fa047d82341a885e512a73d1ec50349c7711d71d0585c3a74d16
BLAKE2b-256 checksum
How to use checksums
b01762e790d485e9c2af569415354b411c6950be52b92da51c71b81164466aef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-musllinux_1_2_aarch64.whl

Download URL clonefile-1.4.1-py3-none-musllinux_1_2_aarch64.whl
Size 100.6 kB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
365564b32d488cc3ee2974a0c7179033823c6e6d696104481c2d4cee4b186840
BLAKE2b-256 checksum
How to use checksums
2fe8fbfad3d8e1bee5ec735e25faee57dd6c514507be3ee216a56605930d28c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-manylinux_2_28_x86_64.whl

Download URL clonefile-1.4.1-py3-none-manylinux_2_28_x86_64.whl
Size 100.4 kB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1da47e18f594061ed6ecbd9f84e70c1d992b6c753f596a92a911e8dc1229c5a7
BLAKE2b-256 checksum
How to use checksums
bea98c439b77e7dec9ec13e5bd89f20560341eeb2df5d2fa5a95e3542b62c6ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-manylinux_2_28_aarch64.whl

Download URL clonefile-1.4.1-py3-none-manylinux_2_28_aarch64.whl
Size 87.1 kB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
53c565a9da49ebb286b129f6fbba093fb93c6c433e2d4fcd2afa210f0e9476c6
BLAKE2b-256 checksum
How to use checksums
0c9e39f87d60a78907fc0aac6aab273da4718bd8d2e110fed607d7c0bf7fe251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-macosx_13_0_x86_64.whl

Download URL clonefile-1.4.1-py3-none-macosx_13_0_x86_64.whl
Size 86.6 kB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
7a47bcb0fe77d7508f34dee645e21dfd80d91d473f72285039ca62f0a4c7c283
BLAKE2b-256 checksum
How to use checksums
7a66b1200445b6935a0fa9c05f40cc68a5eeef1de4e73bfcdedd534596d5699e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-macosx_13_0_arm64.whl

Download URL clonefile-1.4.1-py3-none-macosx_13_0_arm64.whl
Size 74.7 kB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
f9dbf65b2f2d97338b434fb5014b9fa548d95cf910c5d9bd484e3966422af9e9
BLAKE2b-256 checksum
How to use checksums
868a633e750207d936dbb16f498eee16c87d31a6bc61c0f9643918c33045244c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / clonefile-1.4.1-py3-none-any.whl

Download URL clonefile-1.4.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9a496f089dfaa916596447c57b6f9bc1cf0db96a68973e99f4221c6d3ad85c9
BLAKE2b-256 checksum
How to use checksums
9c52cc75019593d62e880db24651e1c1a0d1615c62548e1a3065fdb8ec12b3af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for clonefile 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