Mercurial > hg > buttercup
annotate buttercup/checkout.py @ 18:151862a0a711
begin restructuring to something more modular and extensible
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 30 May 2011 13:40:13 -0700 |
parents | 5e5af2af69bf |
children | 1f54294629f9 |
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', |
15
907bc7300be3
add martINI to list of buttercup packages
Jeff Hammel <jhammel@mozilla.com>
parents:
14
diff
changeset
|
32 'martINI', |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
33 'montage', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
34 'webob_view', |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
35 'wordstream'] |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
36 |
6
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
41 def main(args=sys.argv[1:]): |
10 | 42 |
43 # get source repositories | |
44 sources = globals()['sources']() | |
45 | |
46 # 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
|
47 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
|
48 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
|
49 help="install the packages") |
13
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 |
10 | 56 # 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
10 | 62 # 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 |
18
151862a0a711
begin restructuring to something more modular and extensible
Jeff Hammel <jhammel@mozilla.com>
parents:
16
diff
changeset
|
69 # clone the sources |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
70 for source in sources: |
11
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
71 if os.path.exists(source[0]): |
13
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
72 if options.update: |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
73 os.chdir(source[0]) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
74 subprocess.call(['hg', 'pull']) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
75 subprocess.call(['hg', 'update']) |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
76 os.chdir('..') |
ac29f67b4a45
add an option to update the packages
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
77 else: |
16 | 78 print "%s already exists" % source[0] |
11
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
79 else: |
8a54d538646a
dont clone over existing files
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
80 subprocess.call(['hg', 'clone', source[1]]) |
14 | 81 # TODO: add a more intelligent .hg/hgrc |
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 |
10 | 83 # 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
90 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
|
91 main() |