view buttercup/checkout.py @ 47:0274d9d9fcd4

add dev requirements from lemur box
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 12 Nov 2013 10:29:30 -0800
parents 86c3c0d4d434
children 59969aed59fb
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 source
import sys
from buttercup import Buttercup
from optparse import OptionParser

def main(args=sys.argv[1:]):

    # parse command line options
    parser = OptionParser()
    parser.add_option('--setup', 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)

    # list sources if specified
    if options.list:
        buttercup = Buttercup(srcdir=None)
        sources = source.sources(buttercup.sources)
        for s in sources:
            print '%s: %s' % (s.directory_name(s.uri), s.uri)
        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)

    # grow a flower
    buttercup = Buttercup(srcdir=src)

    # clone/update the sources
    buttercup.install()
    # install the python
    if options.setup:        
        buttercup.setup()

if __name__ == '__main__':
    main()