Mercurial > hg > buttercup
view buttercup/checkout.py @ 14:8c4f353e3c7c
TODO on adding an hgrc
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 08 Nov 2010 08:20:49 -0800 |
parents | ac29f67b4a45 |
children | 907bc7300be3 |
line wrap: on
line source
#!/usr/bin/env python """ checks out the source as associated with the buttercup package """ # XXX could/should use e.g. # pip install --editable hg+https://slinkp@bitbucket.org/slinkp/purplevoter#egg=purplevoter # -or - # pip install -r foo.txt import os import sys import subprocess from optparse import OptionParser HG='http://k0s.org/hg' PACKAGES=['bitsyapps', 'bitsyauth', 'bitsyblog', 'bitsytweet', 'buttercup', 'clwapp', 'commentator', 'contenttransformer', 'cropresize', 'decoupage', 'emaildispatcher', 'genshi_view', 'hgpaste', 'lxmlmiddleware', 'montage', 'webob_view', 'wordstream'] def sources(): return [(package, '%s/%s' % (HG, package)) for package in PACKAGES ] def main(args=sys.argv[1:]): # get source repositories sources = globals()['sources']() # parse command line options parser = OptionParser() parser.add_option('--install', action="store_true", default=False, help="install the packages") parser.add_option('--update', action="store_true", default=False, help="update the packages") parser.add_option('--list', action="store_true", default=False, help="list the source to be installed") options, args = parser.parse_args(args) # list sources if specified if options.list: for source in sources: print source[0], source[1] sys.exit(0) # setup the src directory in a virtualenv assert 'VIRTUAL_ENV' in os.environ src = os.path.join(os.environ['VIRTUAL_ENV'], 'src') if not os.path.exists(src): os.mkdir(src) os.chdir(src) # clone othe sources for source in sources: if os.path.exists(source[0]): if options.update: os.chdir(source[0]) subprocess.call(['hg', 'pull']) subprocess.call(['hg', 'update']) os.chdir('..') else: print "%d already exists" else: subprocess.call(['hg', 'clone', source[1]]) # TODO: add a more intelligent .hg/hgrc # install the sources if options.install: for source in sources: os.chdir(source[0]) subprocess.call(['python', 'setup.py', 'develop']) os.chdir('..') if __name__ == '__main__': main()