Registry / serialization / zip-files

zip-files

JSON →
library0.4.1pypypi✓ verified 82d ago

The `zip-files` Python library provides command-line utilities, `zip-files` and `zip-folder`, for creating ZIP archives. It offers an easy, platform-independent way to compress files and folders, allowing control over the internal root folder structure and compression method. The current version is 0.4.1, and its release cadence has been infrequent, with the last update in April 2021.

pip install zip-files
INSTALL
IMPORT
SIG · ZIP-FILES
Z
zip-files
serializationpythonv0.4.1
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.7s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

zip-files
from zip_files import zip_files
from zip_files.api import create_zip_file
zip-folder
from zip_files import zip_folder

This quickstart demonstrates how to use the `create_zip_file` function from the programmatic API to generate a ZIP file. It includes creating two dummy files, zipping them into `my_archive.zip` under a specified root folder, and then cleaning up the generated files. The library also provides command-line tools `zip-files` and `zip-folder`.

import os from zip_files.api import create_zip_file # Create some dummy files for zipping with open('file1.txt', 'w') as f: f.write('Content of file 1') with open('file2.py', 'w') as f: f.write('print("Hello from file 2")') output_zip = 'my_archive.zip' files_to_zip = ['file1.txt', 'file2.py'] root_folder_in_zip = 'my_data' print(f"Creating {output_zip} with files in root folder '{root_folder_in_zip}'...") create_zip_file(output_zip, files_to_zip, root_folder=root_folder_in_zip) print(f"Successfully created {output_zip}") # You can also use the command-line utility # import subprocess # subprocess.run(['zip-files', '-f', 'another_data', 'another_archive.zip', 'file1.txt', 'file2.py']) # Cleanup (optional) os.remove('file1.txt') os.remove('file2.py') os.remove(output_zip)
zip-files --version
Debug
Known issues
gotchaThe `zip-files` package (hyphenated PyPI name) provides CLI utilities and a thin Python API, but it is distinct from Python's built-in `zipfile` module (underscore name). Many online resources refer to the standard `zipfile` module, which offers a more comprehensive API for ZIP archive manipulation.
fix
Ensure you are importing from `zip_files.api` if you intend to use the programmatic interface of this specific library, or `import zipfile` for the standard library functionality.
affects: All versions
gotchaZIP files, especially large or corrupted ones, can be prone to extraction errors such as `BadZipFile` or `BadZipfile` (deprecated alias). This can be caused by incomplete downloads, header corruption, or unsupported compression methods if the archive was created by another tool.
fix
Always validate the integrity of downloaded ZIP files. If encountering issues, try re-downloading the file or using an alternative extraction tool. For programmatic handling, wrap `zipfile.ZipFile` operations in `try-except BadZipFile` blocks. Ensure the correct compression method is specified when creating archives if compatibility is an issue.
affects: All versions
gotchaWhen creating ZIP files, be mindful of the `root_folder` parameter. If not specified, files are added directly to the archive's root. If a `root_folder` is provided, all included files and folders will reside within that single top-level directory upon extraction. This influences how users interact with the extracted content.
fix
Carefully consider the desired structure of the extracted ZIP. Use `-f` or `--root-folder` in the CLI, or the `root_folder` argument in `create_zip_file`, to control the top-level directory.
affects: All versions
Upgrade
Version history
0.4.1latest on PyPI · released Apr 21, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
zip-files — pip install zip-files · libregistry