condazstandard

How to unzip/unpack `.conda` package archive files?


Conda Forge recently converted to exclusively emitting .conda files for its package builds, instead of .tar.gz files. With the tarballs, we could previously use tar to unpack the archive.

How can one unpack the .conda archive files?


Failed attempts

gzip

Naively trying gzip gives

$ gzip -d libtiff-4.5.0-h82bc61c_0.conda 
gzip: libtiff-4.5.0-h82bc61c_0.conda: unknown suffix -- ignored

and forcing the suffix with -S .conda reports

$ gzip -d -S .conda libtiff-4.5.0-h82bc61c_0.conda 
gzip: libtiff-4.5.0-h82bc61c_0.conda: not in gzip format

zstd

The blog post introducing the format mentions zstandard compression format, but using zstd doesn't seem to fare any better:

$ zstd -d libtiff-4.5.0-h82bc61c_0.conda
zstd: libtiff-4.5.0-h82bc61c_0.conda: unknown suffix (.zst/.tzst expected). Can't derive the output file name. Specify it with -o dstFileName. Ignoring.

$ zstd -d -o libtiff libtiff-4.5.0-h82bc61c_0.conda 
zstd: libtiff-4.5.0-h82bc61c_0.conda: unsupported format

Solution

  • Conda provides a Python package, conda-package-handling (see documentation), which comes installed with the base environment. This includes a CLI entry point, cph, for working with Conda packages. One can extract a .conda archive using, for example,

    $ cph extract libtiff-4.5.0-h82bc61c_0.conda
    

    Help Message

    For reference, here is the help message the tool emits:

    $ cph -h
    usage: cph [-h] [-V] {extract,x,create,c,verify,v,transmute,t} ...
    
    optional arguments:
      -h, --help            show this help message and exit
      -V, --version         Show the conda-package-handling version number and exit.
    
    subcommands:
      {extract,x,create,c,verify,v,transmute,t}
        extract (x)         extract package contents
        create (c)          bundle files into a package
        verify (v)          verify converted files against their reference
        transmute (t)       convert from one package type to another