Mercurial > hg > buttercup
annotate buttercup/checkout.py @ 53:af4155b0a260 default tip
add --prefix option
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 03 Nov 2020 07:59:36 -0800 |
parents | b717de8b384f |
children |
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 |
52 | 14 |
2
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 |
52 | 17 from . import source |
18 from .buttercup import Buttercup | |
19 | |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
20 def main(args=sys.argv[1:]): |
10 | 21 |
22 # 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
|
23 parser = OptionParser() |
32
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
24 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
|
25 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
|
26 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
|
27 help="list the source to be installed") |
53 | 28 parser.add_option('--prefix', |
29 help="prefix or http://k0s.org/hg if not specified") | |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
30 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
|
31 |
10 | 32 # 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
|
33 if options.list: |
53 | 34 buttercup = Buttercup(srcdir=None, prefix=options.prefix) |
31 | 35 sources = source.sources(buttercup.sources) |
36 for s in sources: | |
51 | 37 print('%s: %s' % (s.directory_name(s.uri), s.uri)) |
53 | 38 return |
2
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
39 |
10 | 40 # setup the src directory in a virtualenv |
53 | 41 if 'VIRTUAL_ENV' not in os.environ: |
51 | 42 raise AssertionError("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
|
43 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
|
44 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
|
45 os.mkdir(src) |
32
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
46 |
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
47 # grow a flower |
53 | 48 buttercup = Buttercup(srcdir=src, prefix=options.prefix) |
6
e6e80bf0476f
update the way checkout works; maybe should move to pip at some point
Jeff Hammel <k0scist@gmail.com>
parents:
2
diff
changeset
|
49 |
32
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
50 # clone/update the sources |
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
51 buttercup.install() |
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
52 # install the python |
51 | 53 if options.setup: |
32
86c3c0d4d434
drastic rewrite; now use classes == flowers
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
54 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
|
55 |
d5c80480b967
adding script to checkout source packages; should make this more unified in the future
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
56 if __name__ == '__main__': |
53 | 57 sys.exit(main() or 0) |