Mercurial > hg > buttercup
view buttercup/checkout.py @ 25:a54543838686
add test for source demunging
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 30 May 2011 21:11:19 -0700 |
parents | 88f3d83eb858 |
children | f6b768417d27 |
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 buttercup import Buttercup 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', 'martINI', '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 '%s: %s' % (source[0], source[1]) sys.exit(0) # setup the src directory in a virtualenv assert 'VIRTUAL_ENV' in os.environ, "You must have a virtualenv activated" src = os.path.join(os.environ['VIRTUAL_ENV'], 'src') if not os.path.exists(src): os.mkdir(src) os.chdir(src) # clone the 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 "%s already exists" % source[0] else: subprocess.call(['hg', 'clone', source[1]]) # 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()