1# coding: utf-8
2
3# Copyright (c) Jupyter Development Team.
4# Distributed under the terms of the Modified BSD License.
5"""
6Copies jupyter-packaging's setupbase.py to the specified directory.
7If no directory is given, it uses the current directory.
8"""
9
10import argparse
11import os
12import shutil
13
14
15def check_dir(dirpath):
16    if not os.path.isdir(dirpath):
17        raise argparse.ArgumentTypeError(
18            'Given path is not a directory: %s' % dirpath)
19    return os.path.abspath(dirpath)
20
21
22def main(args=None):
23    parser = argparse.ArgumentParser(description=__doc__)
24    parser.add_argument(
25        'destination', type=check_dir, default='.', nargs='?',
26        help="The directory to copy setupbase.py to.",
27        )
28
29    args = parser.parse_args(args)
30
31    here = os.path.dirname(__file__)
32    source = os.path.join(here, 'setupbase.py')
33    destination = args.destination
34
35    shutil.copy(source, destination)
36
37
38if __name__ == '__main__':  # pragma: no cover
39    main()
40