import os import tarfile def make_archive(path): with tarfile.open(path + ".tar.gz", "w:gz") as tar: tar.add(path, arcname=os.path.sep) os.system(f"rm -r {path}")