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. |
| 6 | # |
| 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 | |
| 24 | import optparse |
| 25 | import os |
| 26 | import subprocess |
| 27 | import sys |
| 28 | |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 29 | import install_venv_common as install_venv |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 30 | |
| 31 | |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 32 | class CentOS(install_venv.Fedora): |
Ryota Hashimoto | 67adbd9 | 2013-01-15 04:04:24 -0700 | [diff] [blame] | 33 | """This covers CentOS.""" |
| 34 | |
| 35 | def post_process(self): |
| 36 | if not self.check_pkg('openssl-devel'): |
| 37 | self.yum.install('openssl-devel', check_exit_code=False) |
| 38 | |
| 39 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 40 | def print_help(): |
Attila Fazekas | b2902af | 2013-02-16 16:22:44 +0100 | [diff] [blame] | 41 | """This prints Help.""" |
| 42 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 43 | help = """ |
| 44 | Tempest development environment setup is complete. |
| 45 | |
| 46 | Tempest development uses virtualenv to track and manage Python dependencies |
| 47 | while in development and testing. |
| 48 | |
| 49 | To activate the Tempest virtualenv for the extent of your current shell |
| 50 | session you can run: |
| 51 | |
| 52 | $ source .venv/bin/activate |
| 53 | |
| 54 | Or, if you prefer, you can run commands in the virtualenv on a case by case |
| 55 | basis by running: |
| 56 | |
| 57 | $ tools/with_venv.sh <your command> |
| 58 | |
| 59 | Also, make test will automatically use the virtualenv. |
| 60 | """ |
| 61 | print help |
| 62 | |
| 63 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 64 | def main(argv): |
Matthew Treinish | 51dfee7 | 2013-01-28 15:50:29 -0500 | [diff] [blame] | 65 | root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 66 | venv = os.path.join(root, '.venv') |
| 67 | pip_requires = os.path.join(root, 'tools', 'pip-requires') |
| 68 | test_requires = os.path.join(root, 'tools', 'test-requires') |
| 69 | py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) |
| 70 | project = 'Tempest' |
| 71 | install = install_venv.InstallVenv(root, venv, pip_requires, test_requires, |
| 72 | py_version, project) |
| 73 | if os.path.exists('/etc/redhat-release'): |
| 74 | with open('/etc/redhat-release') as rh_release: |
| 75 | if 'CentOS' in rh_release.read(): |
| 76 | install_venv.Fedora = CentOS |
| 77 | options = install.parse_args(argv) |
| 78 | install.check_python_version() |
| 79 | install.check_dependencies() |
| 80 | install.create_virtualenv(no_site_packages=options.no_site_packages) |
| 81 | install.install_dependencies() |
| 82 | install.post_process() |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 83 | print_help() |
| 84 | |
| 85 | if __name__ == '__main__': |
| 86 | main(sys.argv) |