view buttercup/checkout.py @ 7:fa1dfcb2ec6a

add bitsytweet to software bitsyblog should have
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 08 Jul 2010 11:32:37 -0700
parents e6e80bf0476f
children ac44aa18da38
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',
          '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:]):
    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()