Skip to content

Instantly share code, notes, and snippets.

@scturtle
Last active May 7, 2016 11:18
Show Gist options
  • Select an option

  • Save scturtle/96f59a7a797ff7d56af432995fb82679 to your computer and use it in GitHub Desktop.

Select an option

Save scturtle/96f59a7a797ff7d56af432995fb82679 to your computer and use it in GitHub Desktop.
python packages which is not required by others (like `brew leaves`)
#!/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