Create split ZIP archives compatible with standard tools
Project description
splitzip
Create split ZIP archives compatible with standard tools.
No 7-Zip required. Archives created with splitzip can be extracted using Windows Explorer, WinZip, macOS Archive Utility, and standard unzip on Linux.
Features
- Pure Python, no external dependencies
- Compatible with standard ZIP tools (no proprietary formats)
- Human-friendly size specifications (
"100MB","700MiB","4.7GB") - Progress callbacks for large files
- Context manager support
- CLI tool included
Installation
pip install splitzip
Quick Start
Simple Usage
import splitzip
# Create a split archive from files
splitzip.create(
"backup.zip",
["documents/", "photos/", "important.pdf"],
split_size="650MB"
)
Output files: backup.z01, backup.z02, ..., backup.zip
Context Manager
from splitzip import SplitZipWriter
with SplitZipWriter("backup.zip", split_size="100MB") as zf:
# Add files
zf.write("document.pdf")
zf.write("photos/", recursive=True)
# Add with custom name
zf.write("secret.txt", arcname="data/renamed.txt")
# Add content directly
zf.writestr("hello.txt", b"Hello, World!")
zf.writestr("config.json", '{"key": "value"}')
Advanced Options
from splitzip import SplitZipWriter, STORED, DEFLATED
def on_progress(filename, bytes_done, total_bytes):
pct = (bytes_done / total_bytes) * 100
print(f"\r{filename}: {pct:.1f}%", end="")
def on_volume(volume_num, path):
print(f"Created volume: {path}")
with SplitZipWriter(
"backup.zip",
split_size="700MiB", # DVD size
compression=DEFLATED, # or STORED for no compression
compresslevel=9, # 1-9 (default: 6)
on_volume=on_volume, # Volume creation callback
on_progress=on_progress, # Progress callback
) as zf:
zf.write("large_file.bin")
Streaming from File Objects
import io
from splitzip import SplitZipWriter
data = get_data_from_somewhere()
with SplitZipWriter("archive.zip", split_size="100MB") as zf:
zf.write_fileobj(
io.BytesIO(data),
arcname="streamed.bin",
size=len(data) # Optional, enables progress callback
)
Size Specifications
splitzip accepts sizes in multiple formats:
| Format | Example | Bytes |
|---|---|---|
| Integer | 104857600 |
104,857,600 |
| Bytes | "100B" |
100 |
| Kilobytes (decimal) | "100KB" |
100,000 |
| Megabytes (decimal) | "100MB" |
100,000,000 |
| Gigabytes (decimal) | "4.7GB" |
4,700,000,000 |
| Kibibytes (binary) | "100KiB" |
102,400 |
| Mebibytes (binary) | "700MiB" |
734,003,200 |
| Gibibytes (binary) | "1GiB" |
1,073,741,824 |
Common split sizes:
- CD-ROM:
"650MB"or"700MB" - DVD:
"4.7GB" - FAT32 limit:
"4GiB"(minus 1 byte) - Email attachment:
"25MB"
Command Line Interface
# Create a split archive
splitzip create -o backup.zip -s 100MB file1.txt directory/
# With options
splitzip create -o backup.zip -s 700MiB \
--level 9 \ # Max compression
--verbose \ # Show progress
documents/ photos/
# Store without compression
splitzip create -o backup.zip -s 100MB --store largefile.bin
Output File Naming
splitzip follows the standard ZIP split archive convention:
backup.z01 (first volume)
backup.z02 (second volume)
backup.z03 (third volume)
...
backup.zip (final volume, contains central directory)
All files must be present in the same directory for extraction.
Compatibility
| Tool | Single Volume | Split Archive |
|---|---|---|
| Windows Explorer | ✅ | ✅ |
| WinZip | ✅ | ✅ |
| 7-Zip | ✅ | ✅ |
| macOS Archive Utility | ✅ | ✅* |
Linux unzip |
✅ | ✅** |
Python zipfile |
✅ | ❌ |
* May require all files to be selected and opened together
** May require unzip -F flag for split archives
Limitations
- No ZIP64 support yet: Individual files must be under 4GB, total entries under 65,535
- No encryption: Use filesystem encryption for sensitive data
- No reading/extraction: This is a write-only library (use standard tools to extract)
- No ZSTD/LZMA: Only DEFLATE and STORED compression (for compatibility)
Development
# Clone and install in development mode
git clone https://github.com/jimothy/splitzip
cd splitzip
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=splitzip
# Type checking
mypy src/splitzip
# Linting
ruff check src/splitzip
License
MIT License. See LICENSE for details.
Contributing
Contributions welcome! Please open an issue to discuss major changes before submitting a PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file splitzip-0.1.0.tar.gz.
File metadata
- Download URL: splitzip-0.1.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e29aa457811953f588144eabae6f581d9c0c4b373cea70d0f1bd91749b01006
|
|
| MD5 |
b301e725ea919ab22275f6171e90dcf3
|
|
| BLAKE2b-256 |
cb322e526e43da0bcee40fc5e06c5f999896b0ab6c1403e738fcf361237ee18d
|
File details
Details for the file splitzip-0.1.0-py3-none-any.whl.
File metadata
- Download URL: splitzip-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa88776abfc297b9353d6a05699bdfe682ca49b5bd2b0ec596de8e365754542
|
|
| MD5 |
79a9d436a14c437362ad8fffac2362bd
|
|
| BLAKE2b-256 |
c51362a1da5ffaaedc8d63d639afbdc517e838f501320d48023fe674b09fc720
|