Skip to main content

Extract DEFLATE64 ZIP archives with Python's zipfile API.

Project description

zipfile-deflate64

PyPI

Extract DEFLATE64 ZIP archives with Python's zipfile API.

Installation

pip install zipfile-deflate64

Python 3.6, 3.7, 3.8, and 3.9 supported, with manylinux2014 wheels published to PyPI.

Usage

Anywhere in a Python codebase:

import zipfile_deflate64  # This has the side effect of patching the zipfile module to support DEFLATE64

Alternatively, zipfile_deflate64 re-exports the zipfile API, as a convenience:

import zipfile_deflate64 as zipfile

zipfile.ZipFile(...)
...

Design Rationale

The Problem

Recent versions of Microsoft Windows Explorer use DEFLATE64 compression when creating ZIP files larger than 2GB. With the ubiquity of Windows and the ease of using "Sent to compressed folder", a majority of newly-created large ZIP files use DEFLATE64 compression.

However, support for DEFLATE64 in the open-source ecosystem is awful! Most ZIP libraries have declined to implement DEFLATE64, citing its proprietary nature.

In the .NET ecosystem, the ZipArchive API supports decompression only. In Java, the Apache Commons Compress APIs support both compression and decompression.

The 7-Zip project probably provides the best general-purpose support for compressing and decompressing DEFLATE64, but there are several obstacles to general usability:

In the Python ecosystem in particular, there have been several unfulfilled requests ( [1] [2] [3] ) for DEFLATE64 decompression support.

A Solution

The best hope seems to be the infback9 extension to zlib. This was developed by Mark Adler, the original author of zlib, and is kept in the source repository of zlib, but it is not officially supported and contains no build tooling and is not distributed with zlib packages. Additionally, infback9 provides only low-level support for working with DEFLATE64 bitstreams, with no support for the ZIP archive format (which is out of scope for zlib).

infback9's C-language API is relatively simple, but requires a non-trivial struct and function pointers for initialization and some explicit memory management operations (resizing allocated buffers and proving a Python-friendly malloc) to operate efficiently, so wrapping it with only ctypes seems to be inadequate.

To manage ZIP archive extraction operations, the Python standard library zipfile module provides the essential features and is already ubiquitous in availability and usage. However, zipfile is difficult to extend, as it hardcodes many conditionals for compression formats and does not provide capabilities for easily augmenting or replacing parts of it. Monkey-patching can overcome some of these problems, and the promise of a drop-in, API-compatible patch to a standard library module outweighed the engineering benefits of basing a solution off a more naturally extensible third-party ZIP manipulation package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zipfile-deflate64-0.1.1.tar.gz (371.8 kB view details)

Uploaded Source

Built Distributions

File details

Details for the file zipfile-deflate64-0.1.1.tar.gz.

File metadata

  • Download URL: zipfile-deflate64-0.1.1.tar.gz
  • Upload date:
  • Size: 371.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for zipfile-deflate64-0.1.1.tar.gz
Algorithm Hash digest
SHA256 baebfd3c6179237b9f4c0c74ff0e1c8f41db2005fc90a695204e92aa5922e311
MD5 026f095b7528da6bfea23f7864c6a5b8
BLAKE2b-256 44b3ce55031caac25f6f9942d94b6c3d627a4e36750370aa7e9ef324aa9b43b8

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.1-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97a75af1034b2bb6e0075ee13fd1c322a6dfa7c3b84d6ca54669a54af43dba89
MD5 a13de50fbe02dd008b294e25143d5ade
BLAKE2b-256 bad34e2285b6a0158338d13cbf5774deb79cc012656dfb7f24fadf67d7c78521

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b529adb65af4317d011705e0fdf745e6e3e1ab827aafefc32486c851936c1dd2
MD5 f75385c9b4b24f7101c270a82582c58f
BLAKE2b-256 756230f287d99479157376896406b7219065ec1c25508c0257f001fe2268a293

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7839863e63b921e4213a0d8c758a8f3078a69807d2dcffa09824e82076aa017c
MD5 933be842ce61959e193033a9d5c81278
BLAKE2b-256 a3283eb09228ca3be6785d859437d4f7c1f222f0443b130b76b257bea8d01204

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.1-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4da0a975d7d452ccda75cd99548f9aac5b212b941d2022254ce83145c0528ad4
MD5 ea7be743993647a934bbcb9dcabe4492
BLAKE2b-256 201cb4560884cddc8aa09929d9f4c2525c0ef76f21564bf4162a8e14e15a9b09

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page