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