Skip to content

Commit

Permalink
add channel to leaves export
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalieris committed Aug 15, 2021
1 parent 8549094 commit 62a8dc6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
77 changes: 47 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@

# conda-tree
## conda-tree

conda dependency tree helper

# Install

This helper requires only that `conda-tree.py` be on your path and
that the `conda` and `networkx` packages are installed. This can be
done with `conda` itself if you like:
## Install

```bash
conda install -c conda-forge conda-tree
```

# Usage
## Features

### Query the dependency tree

```bash
# packages that no other package depends on
Expand All @@ -24,7 +22,20 @@ $ conda-tree leaves
$ conda-tree depends samtools
['curl', 'xz', 'libgcc', 'zlib']

# dependencies in a tree form
# which packages depend on a specific package
$ conda-tree whoneeds xz
['samtools', 'bcftools', 'htslib', 'python']

# dependency cycles
$ conda-tree cycles
pip -> python -> pip
pip -> wheel -> python -> pip
```

### Dependencies in tree form

```bash
# dependencies in a tree form
# (redundancies are hidden by default)
$ conda-tree depends -t sqlite
sqlite==3.29.0
Expand All @@ -35,15 +46,6 @@ sqlite==3.29.0
└─ ncurses 6.1 [required: >=6.1,<6.2.0a0]
└─ dependencies of ncurses displayed above

# which packages depend on a specific package
$ conda-tree whoneeds xz
['samtools', 'bcftools', 'htslib', 'python']

# dependency cycles
$ conda-tree cycles
pip -> python -> pip
pip -> wheel -> python -> pip

# full dependency tree
$ conda-tree deptree --full
neovim==0.3.1
Expand All @@ -61,37 +63,52 @@ conda-tree==0.0.4
│ │ ├─ libarchive 3.3.3 [required: >=3.3.3]
│ │ │ ├─ bzip2 1.0.8 [required: >=1.0.6,<2.0a0]
...
```

### Query another env

# query a different conda prefix/env
```bash
# query by path
$ conda-tree -p /conda/envs/trinity leaves
['trinity']

# query by name
$ conda-tree -n trinity leaves
['trinity']
```

# find dangling files that aren't owned by any package
$ conda-tree -n base unowned-files
/home/user/conda/LICENSE.txt

$ conda-tree -n graphviz unowned-files
/home/user/conda/envs/graphviz/var/cache/fontconfig/b67b32625a2bb51b023d3814a918f351-le64.cache-7
/home/user/conda/envs/graphviz/var/cache/fontconfig/f93dd067-84cf-499d-a5a8-645ff5f927dc-le64.cache-7
/home/user/conda/envs/graphviz/var/cache/fontconfig/923e285e415b1073c8df160bee08820f-le64.cache-7
/home/user/conda/envs/graphviz/fonts/.uuid
### Query package files

```bash
# find which package owns a file
$ conda-tree -n graphviz who-owns bin/dot
graphviz bin/dot
graphviz bin/dot2gxl
graphviz bin/dot_builtins

# export a minimal set of dependencies of a env
# find dangling files that aren't owned by any package
$ conda-tree -n base unowned-files
/conda/LICENSE.txt

$ conda-tree -n graphviz unowned-files
/conda/envs/graphviz/var/cache/fontconfig/b67b32625a2bb51b023d3814a918f351-le64.cache-7
/conda/envs/graphviz/var/cache/fontconfig/f93dd067-84cf-499d-a5a8-645ff5f927dc-le64.cache-7
/conda/envs/graphviz/var/cache/fontconfig/923e285e415b1073c8df160bee08820f-le64.cache-7
/conda/envs/graphviz/fonts/.uuid
```

### Generate a minimal set of packages to re-create the env

```bash
# can be used to re-create a env with conda create -n <new-env> --file <dep-file>
$ conda-tree -n graphviz leaves --export
graphviz=2.48.0=h85b4f2f_0
conda-forge::graphviz=2.48.0=h85b4f2f_0
```

# export a graphviz dot notation file of the dependicies tree
### Generate a graph of the dependency tree

```bash
# export a graphviz dot notation file of the dependencies tree
$ conda-tree deptree --dot > file.dot
$ conda-tree depends <package> --dot > file.dot
$ conda-tree whoneeds <package> --dot > file.dot
Expand Down
4 changes: 2 additions & 2 deletions conda-tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import conda.api
import networkx

__version__ = '1.0.0'
__version__ = '1.0.1'

# The number of spaces
TABSIZE = 3
Expand Down Expand Up @@ -308,7 +308,7 @@ def get_cycles(graph):
if args.export:
for p in get_leaves(g):
k = get_package_key(l, p)
print(l[k]['name']+"="+l[k]['version']+"="+l[k]['build'])
print(l[k]['schannel']+'::'+l[k]['name']+"="+l[k]['version']+"="+l[k]['build'])
else:
print(get_leaves(g))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
shutil.copyfile('conda-tree.py', 'conda_tree.py')

setup(name='conda-tree',
version='1.0.0',
version='1.0.1',
description='conda dependency tree helper',
author='Renan Valieris',
url='https://github.com/rvalieris/conda-tree',
Expand Down

0 comments on commit 62a8dc6

Please sign in to comment.