package_streaming module

Unpack conda packages without using a temporary file.

class conda_package_streaming.package_streaming.CondaComponent(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

info = 'info'
pkg = 'pkg'
class conda_package_streaming.package_streaming.TarfileNoSameOwner(*args, umask: int | None = None, **kwargs)

Bases: TarFile

chmod(tarinfo, targetpath)

Set file permissions of targetpath according to tarinfo, respecting umask.

chown(tarinfo, targetpath, numeric_owner)

Override chown to be a no-op, since we don’t want to preserve ownership here. (tarfile.TarFile only lets us toggle all of (chown, chmod, mtime))

conda_package_streaming.package_streaming.stream_conda_component(filename, fileobj=None, component: CondaComponent | str = CondaComponent.pkg, *, encoding='utf-8') Generator[tuple[tarfile.TarFile, tarfile.TarInfo]]

Yield members from .conda’s embedded {component}- tarball. “info” or “pkg”.

For .tar.bz2 packages, yield all members.

Yields (tar, member) tuples. You must only use the current member to prevent tar seeks and scans.

To extract to disk, it’s possible to call tar.extractall(path) on the first result and then ignore the rest of this generator. extractall takes care of some directory permissions/mtime issues, compared to extract or writing out the file objects yourself.

conda_package_streaming.package_streaming.stream_conda_info(filename, fileobj=None) Generator[tuple[tarfile.TarFile, tarfile.TarInfo]]

Yield members from conda’s embedded info/ tarball.

For .tar.bz2 packages, yield all members.

Yields (tar, member) tuples. You must only use the current member to prevent tar seeks and scans.

To extract to disk, it’s possible to call tar.extractall(path) on the first result and then ignore the rest of this generator. extractall takes care of some directory permissions/mtime issues, compared to extract or writing out the file objects yourself.

conda_package_streaming.package_streaming.tar_generator(fileobj, tarfile_open=<bound method TarFile.open of <class 'conda_package_streaming.package_streaming.TarfileNoSameOwner'>>, closefd=False, *, encoding='utf-8') Generator[tuple[tarfile.TarFile, tarfile.TarInfo]]

Yield (tar, member) from fileobj.

Parameters:
  • fileobj – file-like object

  • encoding – “utf-8” passed to TarFile.open(); can be changed for testing.