| 1 |
# Welcome to conda-package-handling's documentation! |
| 2 |
|
| 3 |
`conda-package-handling` is a library and command line utility used to handle |
| 4 |
`.conda` and `.tar.bz2` [conda |
| 5 |
packages](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/packages.html). |
| 6 |
|
| 7 |
`conda` and `conda-build` use `conda_package_handling.api` to create and extract |
| 8 |
conda packages. This package also provides the `cph` command line tool to |
| 9 |
extract, create, and convert between formats. |
| 10 |
|
| 11 |
See also |
| 12 |
[conda-package-streaming](https://github.com/conda-incubator/conda-package-streaming) |
| 13 |
|
| 14 |
## A new major version |
| 15 |
|
| 16 |
As of version 2.x, `conda-package-handling` provides a backwards-compatible |
| 17 |
wrapper around |
| 18 |
[`conda-package-streaming`](https://conda.github.io/conda-package-streaming/), |
| 19 |
plus additional package creation functionality not found in |
| 20 |
`conda-package-streaming`. `conda-package-handling` always expects to read and |
| 21 |
write to the filesystem. If you need a simpler API to extract or inspect conda |
| 22 |
packages, check out |
| 23 |
[`conda-package-streaming`](https://conda.github.io/conda-package-streaming/). |
| 24 |
|
| 25 |
Version 2.x is approximately two times faster extracting `.conda` packages, by |
| 26 |
extracting `.conda`'s embedded `.tar.zst` without first writing it to a |
| 27 |
temporary file. It no longer uses `libarchive` and so is easier to build. |
| 28 |
Extraction does not `chdir` to the output directory, and is thread-safe. |
| 29 |
|
| 30 |
Version 2.x creates `.conda` packages slightly differently as well. |
| 31 |
|
| 32 |
* `.conda`'s `info-` archive comes after the `pkg-` archive. |
| 33 |
* Inside `.conda`, the `info-` and `pkg-`'s ZIP metadata use a fixed timestamp, |
| 34 |
instead of the current time - can be seen with `python -m zipfile -l |
| 35 |
[filename].conda`. |
| 36 |
* `.conda`'s embedded `.tar.zst` strip `uid`/`gid`/`username`/`groupname` |
| 37 |
instead of preserving these from the filesystem. |
| 38 |
* Both `.conda` and `.tar.bz2` are created by Python's standard `zipfile` and |
| 39 |
`tarfile` instead of `libarchive`. |
| 40 |
|
| 41 |
No particular attention has been paid to archiving time which will be dominated |
| 42 |
by the compression algorithm, but this also avoids using a temporary `.tar.zst`. |
| 43 |
|
| 44 |
## Overview |
| 45 |
|
| 46 |
There are two conda formats. The new conda format, described at [.conda file |
| 47 |
format](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/packages.html?highlight=format#conda-file-format), |
| 48 |
consists of an outer, uncompressed ZIP-format container, with 2 inner compressed |
| 49 |
.tar files. It is designed to have much faster metadata access and utilize more |
| 50 |
modern compression algorithms. The old conda format is a `.tar.bz2` archive. |
| 51 |
|
| 52 |
The cph command line tool can transmute (convert) the old package format to the |
| 53 |
new one, and vice versa. |
| 54 |
|
| 55 |
``` |
| 56 |
cph transmute mkl-2018.0.3-1.tar.bz2 .conda |
| 57 |
``` |
| 58 |
|
| 59 |
The new package format is an indexed, uncompressed zip file that contains two |
| 60 |
Zstandard-compressed tarfiles. The info metadata about packages is separated |
| 61 |
into its own tarfile from the rest of the package contents. By doing this, we |
| 62 |
can extract only the metadata, for speeding up operations like indexing. |
| 63 |
|
| 64 |
And, the Zstandard algorithm is much, much faster to decompress than bz2. |
| 65 |
|
| 66 |
Package creation is primarily something that conda-build uses, as cph only |
| 67 |
packages but does not create metadata that makes a conda package useful. |
| 68 |
|
| 69 |
``` |
| 70 |
cph create /path/to/some/dir my-cute-archive.conda |
| 71 |
``` |
| 72 |
|
| 73 |
This would not necessarily create a valid conda package, unless the directory |
| 74 |
being archived contained all the metadata in an "info" directory that a standard |
| 75 |
conda package needs. The .conda file it creates, however, uses all the nice new |
| 76 |
compression formats, though, and you could use cph on some other computer to |
| 77 |
extract it. |
| 78 |
|
| 79 |
## Development |
| 80 |
|
| 81 |
Install this package and its test dependencies; run tests. |
| 82 |
|
| 83 |
``` |
| 84 |
pip install -e ".[test]" |
| 85 |
pytest |
| 86 |
``` |
| 87 |
|
| 88 |
## Contents |
| 89 |
|
| 90 |
```{toctree} |
| 91 |
:maxdepth: 2 |
| 92 |
modules |
| 93 |
changelog |
| 94 |
``` |
| 95 |
|
| 96 |
# Indices and tables |
| 97 |
|
| 98 |
- {ref}`genindex` |
| 99 |
- {ref}`modindex` |
| 100 |
- {ref}`search` |