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.2

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

Total release size: 567.8 kB

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

Download URL clonefile-1.4.2-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
5c73b391ba0c6d0de3f0afd2e4f2585996d824aabc2b140957e89ec80246ebb4
BLAKE2b-256 checksum
How to use checksums
e6d35321a09c3240fe7d6ab452f5bd87aaedad4184919fe45434cf559886dc0a
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.2-py3-none-musllinux_1_2_aarch64.whl

Download URL clonefile-1.4.2-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
c59752a32a3c2510eb47094837b953a7a2d244d1438ca46e032aa65be909a093
BLAKE2b-256 checksum
How to use checksums
a29abe00486a0d48ead98f40fe8355bc954e13e8ac30c6fe2761bca4844ff747
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.2-py3-none-manylinux_2_28_x86_64.whl

Download URL clonefile-1.4.2-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
be849f82532a55178c9bd147ee779e9d316ae3f6a74fa43aa4c96f4ed4a9ffe5
BLAKE2b-256 checksum
How to use checksums
b29a24078dfb3c670346066498379cd6becaa070bede3b84dfe968297d54d78d
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.2-py3-none-manylinux_2_28_aarch64.whl

Download URL clonefile-1.4.2-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
6dbda28175349e40641a3cfc378e1be7a0af971ebef50d492941d3d8c972ef9c
BLAKE2b-256 checksum
How to use checksums
c67bc41c087761540b20b8e0af6a2e341d808ad052235220422227b3870a5f80
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.2-py3-none-macosx_13_0_x86_64.whl

Download URL clonefile-1.4.2-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
045a75c1047880ac7e93e14c2ddb3952b92091cac4343148e14e3756d6fc0bed
BLAKE2b-256 checksum
How to use checksums
949b6f46305822aee7346852f59e5ea81c92b36ce3fd24e3a565df3d4af38960
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.2-py3-none-macosx_13_0_arm64.whl

Download URL clonefile-1.4.2-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
74b0680728b7e5bf472d05f5903dcd9fd63b8771daf2f0329f60445f6e69e69a
BLAKE2b-256 checksum
How to use checksums
474c6b061aede1537ebce51c478033adb05274caa20ef64e3207f17a4c2eafc0
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.2-py3-none-any.whl

Download URL clonefile-1.4.2-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd1752686d53a976038b981391d33e65bd87a867458497fc6b26a1b8fec26153
BLAKE2b-256 checksum
How to use checksums
8510042bf57d65a0dd93d45ab30d37461a293f51db8bd0547bbab427dbbebc9a
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.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.

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