Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2010 United States Government as represented by the |
| 4 | # Administrator of the National Aeronautics and Space Administration. |
| 5 | # All Rights Reserved. |
Monty Taylor | b2ca5ca | 2013-04-28 18:00:21 -0700 | [diff] [blame] | 6 | # flake8: noqa |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 7 | # Copyright 2010 OpenStack, LLC |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 8 | # Copyright 2013 IBM Corp. |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 9 | # |
| 10 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | # not use this file except in compliance with the License. You may obtain |
| 12 | # a copy of the License at |
| 13 | # |
| 14 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | # |
| 16 | # Unless required by applicable law or agreed to in writing, software |
| 17 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 19 | # License for the specific language governing permissions and limitations |
| 20 | # under the License. |
| 21 | |
| 22 | """Installation script for Tempest's development virtualenv.""" |
| 23 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 24 | import os |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 25 | import sys |
| 26 | |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 27 | import install_venv_common as install_venv |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 28 | |
| 29 | |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 30 | class CentOS(install_venv.Fedora): |
Ryota Hashimoto | 67adbd9 | 2013-01-15 04:04:24 -0700 | [diff] [blame] | 31 | """This covers CentOS.""" |
| 32 | |
| 33 | def post_process(self): |
| 34 | if not self.check_pkg('openssl-devel'): |
| 35 | self.yum.install('openssl-devel', check_exit_code=False) |
| 36 | |
| 37 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 38 | def print_help(): |
Attila Fazekas | b2902af | 2013-02-16 16:22:44 +0100 | [diff] [blame] | 39 | """This prints Help.""" |
| 40 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 41 | help = """ |
| 42 | Tempest development environment setup is complete. |
| 43 | |
| 44 | Tempest development uses virtualenv to track and manage Python dependencies |
| 45 | while in development and testing. |
| 46 | |
| 47 | To activate the Tempest virtualenv for the extent of your current shell |
| 48 | session you can run: |
| 49 | |
| 50 | $ source .venv/bin/activate |
| 51 | |
| 52 | Or, if you prefer, you can run commands in the virtualenv on a case by case |
| 53 | basis by running: |
| 54 | |
| 55 | $ tools/with_venv.sh <your command> |
| 56 | |
| 57 | Also, make test will automatically use the virtualenv. |
| 58 | """ |
Chang Bo Guo | c3fd153 | 2013-09-17 23:24:39 -0700 | [diff] [blame] | 59 | print(help) |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 60 | |
| 61 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 62 | def main(argv): |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 63 | root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 64 | venv = os.path.join(root, '.venv') |
Zhenguo Niu | d41413a | 2013-05-29 17:42:42 +0800 | [diff] [blame] | 65 | pip_requires = os.path.join(root, 'requirements.txt') |
| 66 | test_requires = os.path.join(root, 'test-requirements.txt') |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 67 | py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) |
| 68 | project = 'Tempest' |
| 69 | install = install_venv.InstallVenv(root, venv, pip_requires, test_requires, |
| 70 | py_version, project) |
| 71 | if os.path.exists('/etc/redhat-release'): |
| 72 | with open('/etc/redhat-release') as rh_release: |
| 73 | if 'CentOS' in rh_release.read(): |
| 74 | install_venv.Fedora = CentOS |
| 75 | options = install.parse_args(argv) |
| 76 | install.check_python_version() |
| 77 | install.check_dependencies() |
| 78 | install.create_virtualenv(no_site_packages=options.no_site_packages) |
| 79 | install.install_dependencies() |
| 80 | install.post_process() |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 81 | print_help() |
| 82 | |
| 83 | if __name__ == '__main__': |
| 84 | main(sys.argv) |