Last active
May 7, 2016 11:18
-
-
Save scturtle/96f59a7a797ff7d56af432995fb82679 to your computer and use it in GitHub Desktop.
python packages which is not required by others (like `brew leaves`)
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
| #!/usr/bin/env python3 | |
| import os | |
| import json | |
| import glob | |
| import subprocess | |
| files = glob.glob(os.path.expanduser('~/miniconda3/pkgs/cache/*.json')) | |
| deps = {} | |
| for f in files: | |
| j = json.load(open(f)) | |
| for pkg, info in j['packages'].items(): | |
| pkg = '-'.join(pkg.split('-')[:-2]).replace('-', '_') | |
| deps[pkg] = [d.split()[0] for d in info['depends']] | |
| installed = subprocess.getoutput('conda list | tail -n +3 | cut -d " " -f 1') | |
| installed = set(installed.split('\n')) | |
| required = set(dep for dep in deps[pkg] for pkg in installed) | |
| print('\n'.join(installed - required)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment