Last active
October 6, 2024 06:19
-
-
Save Egor3f/c0d00ed00456c180a01354cfd0e4c982 to your computer and use it in GitHub Desktop.
Show the most dependant brew packages (packages that were installed manually with the most dependencies count)
This file contains 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
#!/opt/homebrew/bin/python3 | |
import subprocess | |
curpkg = '' | |
count = 0 | |
pkgs = {} | |
for pkg in subprocess.check_output('brew deps --tree --installed', shell=True).decode('utf-8').split('\n'): | |
pkg = pkg.strip() | |
if len(pkg) > 0 and pkg[0].isalnum(): | |
curpkg = pkg | |
elif len(pkg) > 0: | |
count += 1 | |
else: | |
pkgs[curpkg] = count | |
curpkg = '' | |
count = 0 | |
leaves = subprocess.check_output('brew leaves', shell=True).decode('utf-8').split('\n') | |
leaves = [leave.strip() for leave in leaves] | |
for p, d in sorted(pkgs.items(), key=lambda item: int(item[1]), reverse=False): | |
if p not in leaves: | |
continue | |
print(f'Pkg: {p:<20} deps: {d}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment