annotate buttercup/checkout.py @ 31:f6b768417d27

now listing kinda works
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 31 May 2011 07:39:07 -0700
parents a54543838686
children 86c3c0d4d434
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
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
15 import subprocess
25
a54543838686 add test for source demunging
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
16 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
17 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
18
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
19 HG='http://k0s.org/hg'
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
20 PACKAGES=['bitsyapps',
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
21 'bitsyauth',
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
22 'bitsyblog',
7
fa1dfcb2ec6a add bitsytweet to software bitsyblog should have
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
23 'bitsytweet',
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
24 'buttercup',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
25 'clwapp',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
26 'commentator',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
27 'contenttransformer',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
28 'cropresize',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
29 'decoupage',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
30 'emaildispatcher',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
31 'genshi_view',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
32 'hgpaste',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
33 'lxmlmiddleware',
15
907bc7300be3 add martINI to list of buttercup packages
Jeff Hammel <jhammel@mozilla.com>
parents: 14
diff changeset
34 'martINI',
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
35 'montage',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
36 'webob_view',
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
37 'wordstream']
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
38
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
39 def sources():
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
40 return [(package, '%s/%s' % (HG, package))
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
41 for package in PACKAGES ]
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
42
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
43 def main(args=sys.argv[1:]):
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
44
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
45 # get source repositories
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
46 sources = globals()['sources']()
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
47
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
48 # 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
49 parser = OptionParser()
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
50 parser.add_option('--install', action="store_true", default=False,
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
51 help="install the packages")
13
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
52 parser.add_option('--update', action="store_true", default=False,
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
53 help="update 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
54 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
55 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
56 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
57
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
58 # 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
59 if options.list:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
60 buttercup = Buttercup(srcdir=None)
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
61 sources = source.sources(buttercup.sources)
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
62 for s in sources:
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
63 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
64 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
65
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
66 # 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
67 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
68 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
69 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
70 os.mkdir(src)
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
71 os.chdir(src)
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
72
18
151862a0a711 begin restructuring to something more modular and extensible
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
73 # clone the sources
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
74 for s in sources:
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
75 if os.path.exists(s[0]):
13
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
76 if options.update:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
77 os.chdir(s[0])
13
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
78 subprocess.call(['hg', 'pull'])
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
79 subprocess.call(['hg', 'update'])
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
80 os.chdir('..')
ac29f67b4a45 add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
81 else:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
82 print "%s already exists" % s[0]
11
8a54d538646a dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
83 else:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
84 subprocess.call(['hg', 'clone', s[1]])
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
85
10
ac44aa18da38 add comments
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
86 # install the sources
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
87 if options.install:
31
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
88 for s in sources:
f6b768417d27 now listing kinda works
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
89 os.chdir(s[0])
6
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
90 subprocess.call(['python', 'setup.py', 'develop'])
e6e80bf0476f update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents: 2
diff changeset
91 os.chdir('..')
2
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
92
d5c80480b967 adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff changeset
93 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
94 main()