Registry / http-networking / remotezip2

remotezip2

JSON →
library0.0.2pypypiunverified

remotezip2 is a Python library that provides efficient access to individual files within a remote ZIP archive without requiring the full download of the entire archive. It functions by leveraging HTTP Range requests, making it suitable for scenarios where only specific contents of large remote ZIP files are needed. As a fork of the original `python-remotezip`, it aims for continued maintenance and responsiveness. The current version is 0.0.2, with a relatively slow release cadence, having received a maintenance update in late 2024 since its initial release.

pip install remotezip2
INSTALL
IMPORT
SIG · REMOTEZIP2
R
remotezip2
http-networkingpythonv0.0.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.2 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

RemoteZip
from remotezip2 import RemoteZip
from remotezip2 import RemoteZip

This quickstart demonstrates how to list the contents of a remote ZIP file and extract a specific file using `remotezip2`. It initializes `RemoteZip` with a URL and then uses `namelist()` to see the files and `open()` to read the content of a specific member. The `REMOTE_ZIP_URL` environment variable can be used to specify a different ZIP file for testing.

import os from remotezip2 import RemoteZip # Replace with a URL to a real remote ZIP file that supports HTTP Range headers # For testing, you can use a publicly available ZIP, e.g., one from thematicmapping.org zip_url = os.environ.get('REMOTE_ZIP_URL', 'http://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip') try: with RemoteZip(zip_url) as rz: print(f"Files in remote ZIP at {zip_url}:") for name in rz.namelist(): print(f" - {name}") # Example: Extract a specific file file_to_extract = 'Readme.txt' if file_to_extract in rz.namelist(): print(f"\nExtracting '{file_to_extract}'...") with rz.open(file_to_extract) as remote_file: content = remote_file.read().decode('utf-8') print(f"Content of '{file_to_extract}':\n---\n{content[:200]}...\n---") # Print first 200 chars else: print(f"\nFile '{file_to_extract}' not found in the archive.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure the URL is valid and the server supports HTTP Range requests.")
Debug
Known issues
gotchaThe `extractall()` and `testzip()` methods are generally inefficient for remote ZIPs as they necessitate downloading the entire archive. If these operations are frequently needed, a full download might be more efficient.
fix
Prefer `extract()` or `open()` for individual files. Only use `extractall()` if the full archive download is acceptable.
affects: All
gotchaPerforming negative seek operations (e.g., `seek(-offset, 1)`) within a `ZipExtFile` object is highly inefficient, as it typically triggers a new remote request to restart reading from the beginning of the member content.
fix
Avoid negative seeks when reading individual remote files. If complex random access is required, consider extracting the file locally first.
affects: All
gotchaThe library heavily relies on the remote web server's support for HTTP Range headers to function efficiently. Without this support, the library may fail or resort to full downloads, losing its primary benefit.
fix
Verify that the server hosting the ZIP file supports HTTP Range requests. If not, consider a different approach or server configuration.
affects: All
gotchaAs of February 2026, PyPI is enforcing stricter ZIP file validation (e.g., for wheels), rejecting archives with duplicate filenames or invalid `RECORD` metadata. While `remotezip2` consumes ZIPs, not creates them, consuming a malformed ZIP that would now be rejected by PyPI could lead to unexpected behavior or errors.
fix
Ensure that any remote ZIP files you intend to process with `remotezip2` are well-formed and adhere to modern ZIP file standards to avoid parsing issues, especially those related to central directory and local file header consistency.
affects: All
Upgrade
Version history
0.0.2latest on PyPI · released Dec 1, 2024
Audit
Dependencies
requestsrequiredUsed for making HTTP requests, including Range headers, to fetch parts of the remote ZIP file.
Agent activity
18 hits · last 30 days
node
18
Resources
remotezip2 — pip install remotezip2 · libregistry