From 62a8dc6cf18c8f0572891a6efe56dc8e81e8dc86 Mon Sep 17 00:00:00 2001 From: rvalieris Date: Sun, 15 Aug 2021 15:57:19 -0300 Subject: [PATCH] add channel to leaves export --- README.md | 77 +++++++++++++++++++++++++++++++-------------------- conda-tree.py | 4 +-- setup.py | 2 +- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 6f41250..8f72a3e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 @@ -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 --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 --dot > file.dot $ conda-tree whoneeds --dot > file.dot diff --git a/conda-tree.py b/conda-tree.py index 6dcdad8..dad5fcb 100755 --- a/conda-tree.py +++ b/conda-tree.py @@ -11,7 +11,7 @@ import conda.api import networkx -__version__ = '1.0.0' +__version__ = '1.0.1' # The number of spaces TABSIZE = 3 @@ -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)) diff --git a/setup.py b/setup.py index bde5d0f..b153329 100644 --- a/setup.py +++ b/setup.py @@ -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',