-
-
Save gabrielcnr/ad5da0d04b0bf755b2253cedc1e90a15 to your computer and use it in GitHub Desktop.
Render the dependency graph for your conda environment (needs graphviz!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import glob | |
| from os.path import join, basename | |
| # install this with "conda install -c conda-forge python-graphviz" | |
| import graphviz as gv | |
| # path to your conda environment | |
| path = '/tmp/foo' | |
| dg = gv.Digraph(filename='env-%s' % basename(path), format='svg') | |
| for json_file in glob.glob(join(path, 'conda-meta', '*.json')): | |
| print('reading', json_file) | |
| j = json.load(open(json_file)) | |
| dg.node(j['name']) | |
| for dep in j.get('depends', []): | |
| dg.edge(j['name'], dep.split(' ')[0]) | |
| dg.render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment