Created
July 9, 2012 01:46
-
-
Save marciomazza/3073752 to your computer and use it in GitHub Desktop.
Strips the buildout cache from older egg versions
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/python | |
import os | |
from itertools import groupby | |
from shutil import rmtree | |
from pkg_resources import parse_version | |
def main(): | |
"""Strips the buildout cache from older egg versions | |
""" | |
cache_dir = os.getenv("HOME") + '/.buildout/eggs' | |
eggs = sorted(os.listdir(cache_dir), key=parse_version, reverse=True) | |
print "Removing old eggs from buildout cache:" | |
for _, g in groupby(eggs, lambda x: x.split('-')[0]): | |
g.next() # skip the one with the highest version (or single one) | |
for egg in g: | |
rmtree(os.path.join(cache_dir, egg)) | |
print "- %s" % egg | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment