1# Copyright 2010 United States Government as represented by the 2# Administrator of the National Aeronautics and Space Administration. 3# All Rights Reserved. 4# 5# Copyright 2010 OpenStack Foundation 6# Copyright 2013 IBM Corp. 7# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. 8# 9# Licensed under the Apache License, Version 2.0 (the "License"); you may 10# not use this file except in compliance with the License. You may obtain 11# a copy of the License at 12# 13# http://www.apache.org/licenses/LICENSE-2.0 14# 15# Unless required by applicable law or agreed to in writing, software 16# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 18# License for the specific language governing permissions and limitations 19# under the License. 20 21import os 22import sys 23 24from six.moves import configparser 25 26import install_venv_common as install_venv 27 28 29def print_help(project, venv, root): 30 help = """ 31 %(project)s development environment setup is complete. 32 33 %(project)s development uses virtualenv to track and manage Python 34 dependencies while in development and testing. 35 36 To activate the %(project)s virtualenv for the extent of your current 37 shell session you can run: 38 39 $ . %(venv)s/bin/activate 40 41 Or, if you prefer, you can run commands in the virtualenv on a case by 42 case basis by running: 43 44 $ %(root)s/tools/with_venv.sh <your command> 45 """ 46 print(help % dict(project=project, venv=venv, root=root)) 47 48 49def main(argv): 50 root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 51 52 if os.environ.get('tools_path'): 53 root = os.environ['tools_path'] 54 venv = os.path.join(root, '.venv') 55 if os.environ.get('venv'): 56 venv = os.environ['venv'] 57 58 pip_requires = os.path.join(root, 'requirements.txt') 59 test_requires = os.path.join(root, 'test-requirements.txt') 60 py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) 61 setup_cfg = configparser.ConfigParser() 62 setup_cfg.read('setup.cfg') 63 project = setup_cfg.get('metadata', 'name') 64 65 install = install_venv.InstallVenv( 66 root, venv, pip_requires, test_requires, py_version, project) 67 options = install.parse_args(argv) 68 install.check_python_version() 69 install.check_dependencies() 70 install.create_virtualenv(no_site_packages=options.no_site_packages) 71 install.install_dependencies() 72 print_help(project, venv, root) 73 74 75if __name__ == '__main__': 76 main(sys.argv) 77