view buttercup/checkout.py @ 6:e6e80bf0476f

update the way checkout works; maybe should move to pip at some point
author Jeff Hammel <k0scist@gmail.com>
date Mon, 29 Mar 2010 11:57:48 -0700
parents d5c80480b967
children fa1dfcb2ec6a
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=['bitsyauth',
          'bitsyblog',
          '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:]):
    parser = OptionParser()
    parser.add_option('--install', action="store_true", default=False,
                      help="install the packages")
    parser.add_option('--list', action="store_true", default=False,
                      help="list the source to be installed")
    options, args = parser.parse_args(args)

    sources = globals()['sources']()
    if options.list:
        for source in sources:
            print source[0], source[1]
        sys.exit(0)

    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)

    for source in sources:
        subprocess.call(['hg', 'clone', source[1]])

    if options.install:
        for source in sources:
            os.chdir(source[0])
            subprocess.call(['python', 'setup.py', 'develop'])
            os.chdir('..')

if __name__ == '__main__':
    main()