Skip to main content

Download metadata from conda packages without transferring entire file.

Project description

conda-package-streaming

Download conda metadata from packages without transferring entire file. Get metadata from local .tar.bz2 packages without reading entire files.

Uses enhanced pip lazy_wheel to fetch a file out of .conda with no more than 3 range requests, but usually 2.

Uses tar = tarfile.open(fileobj=...) to stream remote .tar.bz2. Closes the HTTP request once desired files have been seen.

Quickstart

The basic API yields (tarfile, member) tuples from conda files as tarfile is needed to extract member. Note the .tar.bz2 format yields all members, not just info/, from stream_conda_info / stream_conda_component, while the .conda format yields members from the requested inner archive — allowing the caller to decide when to stop reading.

From a url,

from conda_package_streaming.url import stream_conda_info
# url = (ends with .conda or .tar.bz2)
for tar, member in stream_conda_info(url):
    if member.name == "info/index.json":
        index_json = json.load(tar.extractfile(member))
        break

From s3,

client = boto3.client("s3")
from conda_package_streaming.s3 import stream_conda_info
# key = (ends with .conda or .tar.bz2)
for tar, member in stream_conda_info(client, bucket, key):
    if member.name == "info/index.json":
        index_json = json.load(tar.extractfile(member))
        break

From a filename,

from conda_package_streaming import package_streaming
# filename = (ends with .conda or .tar.bz2)
for tar, member in package_streaming.stream_conda_info(filename):
    if member.name == "info/index.json":
        index_json = json.load(tar.extractfile(member))
        break

From a file-like object,

from contextlib import closing

from conda_package_streaming.url import reader_for_conda_url
from conda_package_streaming.package_streaming import stream_conda_component
filename, conda = reader_for_conda_url(url)

# file object must be seekable for `.conda` format, but merely readable for `.tar.bz2`
with closing(conda):
    for tar, member in stream_conda_component(filename, conda, component="info"):
        if member.name == "info/index.json":
            index_json = json.load(tar.extractfile(member))
            break

Package goals

  • Extract conda packages (both formats)

  • Easy to install from pypi or conda

  • Do the least amount of I/O possible (no temporary files, transfer partial packages)

  • Open files from the network / standard HTTP / s3

  • Continue using conda-package-handling to create .conda packages

Generating documentation

Uses markdown, furo theme. Requires newer mdit-py-plugins.

pip install conda-package-streaming[docs]

One time: sphinx-apidoc -o docs .

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

conda_package_streaming-0.3.0.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

conda_package_streaming-0.3.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file conda_package_streaming-0.3.0.tar.gz.

File metadata

File hashes

Hashes for conda_package_streaming-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ad0d084a08cb0a87e8c61f22777b10852ec6743970d1c98d982b5903903964fc
MD5 ac5528316e0a71725e465680437bbe7e
BLAKE2b-256 b82474cc045ea0e3b21d065ec17cdc03e16f4307e9042d5a4510993406e3f3b5

See more details on using hashes here.

Provenance

File details

Details for the file conda_package_streaming-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for conda_package_streaming-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3829693690aa98f54865944fafaeb67956e949454e4f4417f39eb476ff8d0ae1
MD5 845a9ac0ca229249862dc5ce97941960
BLAKE2b-256 08b90c6ca7f92faaf18731647536ed34852b328bb363a4530620fd125ffcc3f2

See more details on using hashes here.

Provenance

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