5Aug/090
Get all versions of your development eggs
On a big Zope/Plone project with a long list of eggs in development, you must know each version of each egg when you want to release them and configure production / pre-production buildout.
Instead of looking into each egg's VERSION.txt or setup.py, here's a script to list them all. The result can be copy/past in your buildout's version.cfg .
list_versions.py
import stat, os, re re_version = re.compile(r"""^version\s*=\s*(?:"|')(.*?)(?:"|')""", re.MULTILINE|re.DOTALL) re_name = re.compile(r"""name\s*=\s*(?:"|')(.*?)(?:"|')""", re.MULTILINE|re.DOTALL) def _get_setup(base): """returns setup content""" setup_py = os.path.join(os.getcwd(), base, 'setup.py') return open(setup_py).read() if __name__ == '__main__': print 'src versions :\n==============\n\n' files=os.listdir(".") files=[filename for filename in files if filename[0] != '.'] for egg in files: if egg[0]=='.': continue # ignore hidden files try: stat_info=os.lstat(egg) except: continue # bad file if not stat.S_ISDIR(stat_info.st_mode): continue # ignore files try: setup = _get_setup(egg) print '%s = %s'%(re_name.search(setup).group(1), re_version.search(setup).group(1), ) except: continue # prevent crash when setup.py doesn't exist