annotate buttercup/checkout.py @ 42:c008855cf3a9

fix typo
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 25 Nov 2011 19:49:31 -0800
parents 86c3c0d4d434
children 59969aed59fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
3 """
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
4 checks out the source as associated with the buttercup package
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
5 """
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
6
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
7 # XXX could/should use e.g.
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
8 # pip install --editable hg+https://slinkp@bitbucket.org/slinkp/purplevoter#egg=purplevoter
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
9 # -or -
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
10 # pip install -r foo.txt
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
11
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
12 import os
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
13 import source
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
14 import sys
25
a54543838686 add test for source demunging
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
15 from buttercup import Buttercup
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
16 from optparse import OptionParser
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
17
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
18 def main(args=sys.argv[1:]):
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
19
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
20 # parse command line options
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
21 parser = OptionParser()
32
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
22 parser.add_option('--setup', action="store_true", default=False,
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
23 help="install the packages")
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
24 parser.add_option('--list', action="store_true", default=False,
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
25 help="list the source to be installed")
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
26 options, args = parser.parse_args(args)
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
27
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
28 # list sources if specified
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
29 if options.list:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
30 buttercup = Buttercup(srcdir=None)
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
31 sources = source.sources(buttercup.sources)
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
32 for s in sources:
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
33 print '%s: %s' % (s.directory_name(s.uri), s.uri)
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
34 sys.exit(0)
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
35
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
36 # setup the src directory in a virtualenv
18
151862a0a711 begin restructuring to something more modular and extensible
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
37 assert 'VIRTUAL_ENV' in os.environ, "You must have a virtualenv activated"
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
38 src = os.path.join(os.environ['VIRTUAL_ENV'], 'src')
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
39 if not os.path.exists(src):
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
40 os.mkdir(src)
32
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
41
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
42 # grow a flower
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
43 buttercup = Buttercup(srcdir=src)
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
44
32
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
45 # clone/update the sources
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
46 buttercup.install()
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
47 # install the python
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
48 if options.setup:
86c3c0d4d434 drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
49 buttercup.setup()
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
50
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
51 if __name__ == '__main__':
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
52 main()