1# Copyright 2020 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14"""Runnable module that sets up virtualenv for Pigweed.""" 15 16import argparse 17import os 18import sys 19 20# TODO(pwbug/67) switch back to 'from pw_env_setup import virtualenv_setup'. 21# from pw_env_setup import virtualenv_setup 22# pylint: disable=import-error 23import install as virtualenv_setup # type: ignore 24# pylint: enable=import-error 25 26 27def _main(): 28 parser = argparse.ArgumentParser(description=__doc__) 29 30 project_root = os.environ.get('PW_PROJECT_ROOT', None) 31 32 parser.add_argument('--project-root', 33 default=project_root, 34 required=not project_root, 35 help='Path to overall project root.') 36 parser.add_argument('--venv_path', 37 required=True, 38 help='Path at which to create the venv') 39 parser.add_argument('-r', 40 '--requirements', 41 default=[], 42 action='append', 43 help='requirements.txt files to install') 44 parser.add_argument('--gn-target', 45 dest='gn_targets', 46 default=[], 47 action='append', 48 type=virtualenv_setup.GnTarget, 49 help='GN targets that install packages') 50 parser.add_argument('--quick-setup', 51 dest='full_envsetup', 52 action='store_false', 53 default='PW_ENVSETUP_FULL' in os.environ, 54 help=('Do full setup or only minimal checks to see if ' 55 'full setup is required.')) 56 parser.add_argument('--python', 57 default=sys.executable, 58 help='Python to use when creating virtualenv.') 59 60 virtualenv_setup.install(**vars(parser.parse_args())) 61 62 return 0 63 64 65if __name__ == '__main__': 66 sys.exit(_main()) 67