Skip to main content

Assorted tar related things, including a fast tar-based copy.

Latest release 20260531: Update because an IterableQueue no longer has a .open() method.

My most heavily used use for this is my cpdir script which does a high performance directory copy by piping 2 tars together. It runs this:

from cs.tarutils import traced_cpdir
sys.exit(traced_cpdir(*sys.argv[1:]))

Short summary:

  • tar: Tar up the contents of srcpaths to output. Return the Popen object for the tar command.
  • traced_cpdir: Copy a directory to a new place using piped tars with progress reporting. Return 0 if both tars succeed, nonzero otherwise.
  • traced_untar: Read tar data from tarfd and extract. Return the tar exit code.

Module contents:

  • tar(*srcpaths: List[str], chdirpath='.', output, tar_exe='tar', bcount=2048): Tar up the contents of srcpaths to output. Return the Popen object for the tar command.

    Parameters:

    • srcpaths: source filesystem paths
    • chdirpath: optional directory to which to chdir before accessing srcpaths
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048
  • traced_cpdir(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x10b0b7920>, **kw): Copy a directory to a new place using piped tars with progress reporting. Return 0 if both tars succeed, nonzero otherwise.

    Parameters:

    • srcdirpath: the source directory filesystem path
    • dstdirpath: the destination directory filesystem path, which must not already exist
    • label: optional label for the progress bar
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048
  • traced_untar(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x10b0b7560>, **kw): Read tar data from tarfd and extract. Return the tar exit code.

    Parameters:

    • tarfd: the source tar data, suitable for subprocess.Popen's stdin parameter
    • chdirpath: optional directory to which to chdir before accessing srcpaths
    • label: optional label for the progress bar
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048

Release Log

Release 20260531: Update because an IterableQueue no longer has a .open() method.

Release 20240318: Initial PyPI release with nice traced_cpdir() function.

Release files for cs-tarutils 20260531

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

Source distribution (sdist)

Source distribution for cs-tarutils 20260531
File Size Uploaded
cs_tarutils-20260531.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-tarutils 20260531
File Interpreter ABI Platform
cs_tarutils-20260531-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.1 kB

Release files / cs_tarutils-20260531.tar.gz

Download URL cs_tarutils-20260531.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6855e4d5084e3512ab40a340b416d3b03bc19de9b02cd7996838b5fa2ff4e8e2
BLAKE2b-256 checksum
How to use checksums
51f660503906a4f9dd46f71cbe883fb2791d0dc21d5c99cf6f3f65bb4efdc050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / cs_tarutils-20260531-py2.py3-none-any.whl

Download URL cs_tarutils-20260531-py2.py3-none-any.whl
Size 5.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a0890f523d479e2102f2d2ac02b4faa261a52a6e0640b89c947af6a4675bbcfa
BLAKE2b-256 checksum
How to use checksums
14b2b4983e60664cbdeb9b8b3139c838c44873057ae3037036c0495b5f60c820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

20260531 This release

2 release files

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