transmute module¶
Convert .tar.bz2 to .conda
Uses tempfile.SpooledTemporaryFile
to buffer pkg-*.tar
and
info-*.tar
, then compress directly into an open ZipFile at the end.
SpooledTemporaryFile buffers the first 10MB of the package and its metadata in
memory, but writes out to disk for larger packages.
- conda_package_streaming.transmute.transmute(package, path, *, compressor: ~typing.Callable[[], ~zstd.ZstdCompressor] = <function <lambda>>, is_info: ~typing.Callable[[str], bool] = <function <lambda>>) Path ¶
Convert .tar.bz2 conda package to .conda-format under path.
- Parameters:
package – path to .tar.bz2 conda package
path – destination path for transmuted .conda package
compressor – A function that creates instances of
zstandard.ZstdCompressor()
to override defaults.is_info – A function that returns True if a file belongs in the
info
component of a .conda package.conda-package-handling
(not this packageconda-package-streaming
) uses a set of regular expressions to keep expected items in the info- component, while other items starting withinfo/
wind up in the pkg- component.
- Returns:
Path to transmuted package.
- conda_package_streaming.transmute.transmute_stream(stem, path, *, compressor: ~typing.Callable[[], ~zstd.ZstdCompressor] = <function <lambda>>, is_info: ~typing.Callable[[str], bool] = <function <lambda>>, package_stream: ~typing.Iterator[tuple[~tarfile.TarFile, ~tarfile.TarInfo]])¶
Convert (TarFile, TarInfo) iterator like those produced by
stream_conda_component
to .conda-format under path. Allows for more creative data sources.e.g. recompress
.conda
:transmute_stream(..., package_stream=itertools.chain( stream_conda_component("package.conda", component=CondaComponent.pkg), stream_conda_component("package.conda", component=CondaComponent.info), ))
This example could move files between the
pkg-
andinfo-
components depending on theis_info
function.- Parameters:
stem – output filename without extension
path – destination path for transmuted .conda package
compressor – A function that creates instances of
zstandard.ZstdCompressor()
to override defaults.is_info – A function that returns True if a file belongs in the
info
component of a .conda package.conda-package-handling
(not this packageconda-package-streaming
) uses a set of regular expressions to keep expected items in the info- component, while other items starting withinfo/
wind up in the pkg- component.package_stream – Iterator of (Tarfile, TarInfo) tuples.
- Returns:
Path to transmuted package.
- conda_package_streaming.transmute.transmute_tar_bz2(package: str, path) Path ¶
Convert .conda package to .tar.bz2 format under path.
Can recompress .tar.bz2 packages.
- Parameters:
package – path to .conda or .tar.bz2 package.
path – destination path for transmuted package.
- Returns:
Path to transmuted package.