import os import py7zr import multivolumefile ARCHIVE_PATH="/tmp" random_file_size = 400_240 num_files = 8000 volume_size = 10_000_000 target = f"{ARCHIVE_PATH}/test.tmp" def random_file(): with open(target, 'wb') as fout: fout.write(os.urandom(random_file_size)) with multivolumefile.open( f"{ARCHIVE_PATH}/zip/test.7z", mode='wb', volume=volume_size, ) as multi_handler: with py7zr.SevenZipFile( multi_handler, 'w', ) as handler: for i in range(num_files): random_file() handler.write(target, f"test{i}.tmp")