TAR libraries for Python
Python’s standard library module tarfile reads and writes ustar, GNU and pax archives and handles gzip, bzip2 and xz compression by itself, plus Zstandard since Python 3.14. It’s what pip, setuptools and most Python tools use for .tar.gz source distributions, so there is rarely a reason to install anything else. For one API over ZIP, TAR and other formats, shutil.unpack_archive and shutil.make_archive wrap tarfile and zipfile.
- tarfile Python's tarfile module reads and writes TAR, .tar.gz, .tar.xz and .tar.zst. How to list, extract safely, create archives and add files from memory, with code.