Mercurial > hg > buttercup
comparison 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 |
comparison
equal
deleted
inserted
replaced
52:b717de8b384f | 53:af4155b0a260 |
---|---|
23 parser = OptionParser() | 23 parser = OptionParser() |
24 parser.add_option('--setup', action="store_true", default=False, | 24 parser.add_option('--setup', action="store_true", default=False, |
25 help="install the packages") | 25 help="install the packages") |
26 parser.add_option('--list', action="store_true", default=False, | 26 parser.add_option('--list', action="store_true", default=False, |
27 help="list the source to be installed") | 27 help="list the source to be installed") |
28 parser.add_option('--prefix', | |
29 help="prefix or http://k0s.org/hg if not specified") | |
28 options, args = parser.parse_args(args) | 30 options, args = parser.parse_args(args) |
29 | 31 |
30 # list sources if specified | 32 # list sources if specified |
31 if options.list: | 33 if options.list: |
32 buttercup = Buttercup(srcdir=None) | 34 buttercup = Buttercup(srcdir=None, prefix=options.prefix) |
33 sources = source.sources(buttercup.sources) | 35 sources = source.sources(buttercup.sources) |
34 for s in sources: | 36 for s in sources: |
35 print('%s: %s' % (s.directory_name(s.uri), s.uri)) | 37 print('%s: %s' % (s.directory_name(s.uri), s.uri)) |
36 sys.exit(0) | 38 return |
37 | 39 |
38 # setup the src directory in a virtualenv | 40 # setup the src directory in a virtualenv |
39 if 'VIRTUAL_ENV' in os.environ: | 41 if 'VIRTUAL_ENV' not in os.environ: |
40 raise AssertionError("You must have a virtualenv activated") | 42 raise AssertionError("You must have a virtualenv activated") |
41 src = os.path.join(os.environ['VIRTUAL_ENV'], 'src') | 43 src = os.path.join(os.environ['VIRTUAL_ENV'], 'src') |
42 if not os.path.exists(src): | 44 if not os.path.exists(src): |
43 os.mkdir(src) | 45 os.mkdir(src) |
44 | 46 |
45 # grow a flower | 47 # grow a flower |
46 buttercup = Buttercup(srcdir=src) | 48 buttercup = Buttercup(srcdir=src, prefix=options.prefix) |
47 | 49 |
48 # clone/update the sources | 50 # clone/update the sources |
49 buttercup.install() | 51 buttercup.install() |
50 # install the python | 52 # install the python |
51 if options.setup: | 53 if options.setup: |
52 buttercup.setup() | 54 buttercup.setup() |
53 | 55 |
54 if __name__ == '__main__': | 56 if __name__ == '__main__': |
55 main() | 57 sys.exit(main() or 0) |