Conda Package Streaming

0.12.0 · active · verified Thu Apr 16

An efficient library to read from new and old format .conda and .tar.bz2 conda packages. It enables downloading conda metadata from packages without transferring the entire file and getting metadata from local .tar.bz2 packages without reading entire files. The library, currently at version 0.12.0, uses enhanced pip lazy_wheel for `.conda` files and `tarfile.open` for `.tar.bz2` to stream data efficiently. It maintains a regular release cadence, with major updates roughly every few months.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to stream package metadata (specifically `info/index.json`) from a remote `.conda` or `.tar.bz2` package URL without downloading the entire file. It iterates through the package's members and extracts the `index.json` content.

import json
from conda_package_streaming.url import stream_conda_info

# Replace with a valid .conda or .tar.bz2 URL
# For example: url = 'https://repo.anaconda.com/pkgs/main/linux-64/python-3.9.7-h62f7035_1.conda'
url = 'https://repo.anaconda.com/pkgs/main/linux-64/zlib-1.2.13-h5eee18b_0.conda'

print(f"Streaming info from: {url}")

try:
    found_index_json = False
    for tar, member in stream_conda_info(url):
        if member.name == 'info/index.json':
            index_json = json.load(tar.extractfile(member))
            print("\n--- Found info/index.json ---")
            print(json.dumps(index_json, indent=2))
            found_index_json = True
            break # Stop once index.json is found
    
    if not found_index_json:
        print("\n--- info/index.json not found in package ---")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →