Mercurial > hg > buttercup
annotate buttercup/checkout.py @ 13:ac29f67b4a45
add an option to update the packages
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 08 Nov 2010 08:18:34 -0800 |
parents | 8a54d538646a |
children | 8c4f353e3c7c |
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 |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 import sys |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
14 import subprocess |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 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
|
16 |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
17 HG='http://k0s.org/hg' |
10 | 18 PACKAGES=['bitsyapps', |
19 'bitsyauth', | |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
20 'bitsyblog', |
7
fa1dfcb2ec6a
add bitsytweet to software bitsyblog should have
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
21 'bitsytweet', |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
22 'buttercup', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
23 'clwapp', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
24 'commentator', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
25 'contenttransformer', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
26 'cropresize', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
27 'decoupage', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
28 'emaildispatcher', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
29 'genshi_view', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
30 'hgpaste', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
31 'lxmlmiddleware', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
32 'montage', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
33 'webob_view', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
34 'wordstream'] |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
35 |
6
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
40 def main(args=sys.argv[1:]): |
10 | 41 |
42 # get source repositories | |
43 sources = globals()['sources']() | |
44 | |
45 # 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
|
46 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
|
47 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
|
48 help="install the packages") |
13
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 |
10 | 55 # 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
|
56 if options.list: |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
57 for source in 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
|
58 print source[0], source[1] |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
59 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
|
60 |
10 | 61 # setup the src directory in a virtualenv |
6
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
62 assert 'VIRTUAL_ENV' in os.environ |
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 |
13
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
68 # clone othe sources |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
69 for source in sources: |
11
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
70 if os.path.exists(source[0]): |
13
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
71 if options.update: |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
72 os.chdir(source[0]) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
73 subprocess.call(['hg', 'pull']) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
74 subprocess.call(['hg', 'update']) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
75 os.chdir('..') |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
76 else: |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
77 print "%d already exists" |
11
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
78 else: |
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
79 subprocess.call(['hg', 'clone', source[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
|
80 |
10 | 81 # 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
|
82 if options.install: |
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
83 for source in sources: |
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
84 os.chdir(source[0]) |
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
85 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
|
86 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
|
87 |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
88 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
|
89 main() |