blob: d6d9c8e38bc5a56e83e3c9de0242688964d7aefa [file] [log] [blame]
Matthew Treinish8e937d72012-12-14 11:11:41 -05001# Copyright 2010 United States Government as represented by the
2# Administrator of the National Aeronautics and Space Administration.
3# All Rights Reserved.
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +09004#
ZhiQiang Fan39f97222013-09-20 04:49:44 +08005# Copyright 2010 OpenStack Foundation
Matthew Treinish51dfee72013-01-28 15:50:29 -05006# Copyright 2013 IBM Corp.
Matthew Treinish8e937d72012-12-14 11:11:41 -05007#
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 Treinish8e937d72012-12-14 11:11:41 -050020import os
Matthew Treinish8e937d72012-12-14 11:11:41 -050021import sys
22
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090023import install_venv_common as install_venv # noqa
Matthew Treinish8e937d72012-12-14 11:11:41 -050024
25
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090026def print_help(venv, root):
Matthew Treinish8e937d72012-12-14 11:11:41 -050027 help = """
tanlin4956a642014-02-13 16:52:11 +080028 OpenStack development environment setup is complete.
Matthew Treinish8e937d72012-12-14 11:11:41 -050029
tanlin4956a642014-02-13 16:52:11 +080030 OpenStack development uses virtualenv to track and manage Python
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090031 dependencies while in development and testing.
Matthew Treinish8e937d72012-12-14 11:11:41 -050032
tanlin4956a642014-02-13 16:52:11 +080033 To activate the OpenStack virtualenv for the extent of your current shell
Matthew Treinish8e937d72012-12-14 11:11:41 -050034 session you can run:
35
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090036 $ source %s/bin/activate
Matthew Treinish8e937d72012-12-14 11:11:41 -050037
38 Or, if you prefer, you can run commands in the virtualenv on a case by case
39 basis by running:
40
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090041 $ %s/tools/with_venv.sh <your command>
Matthew Treinish8e937d72012-12-14 11:11:41 -050042
43 Also, make test will automatically use the virtualenv.
44 """
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090045 print(help % (venv, root))
Matthew Treinish8e937d72012-12-14 11:11:41 -050046
47
Matthew Treinish8e937d72012-12-14 11:11:41 -050048def main(argv):
Matthew Treinish51dfee72013-01-28 15:50:29 -050049 root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090050
ghanshyamf5360ff2015-06-29 13:32:01 +090051 if os.environ.get('TOOLS_PATH'):
52 root = os.environ['TOOLS_PATH']
Matthew Treinish51dfee72013-01-28 15:50:29 -050053 venv = os.path.join(root, '.venv')
ghanshyamf5360ff2015-06-29 13:32:01 +090054 if os.environ.get('VENV'):
55 venv = os.environ['VENV']
Masayuki Igawaf3d92ec2013-12-27 14:15:07 +090056
Zhenguo Niud41413a2013-05-29 17:42:42 +080057 pip_requires = os.path.join(root, 'requirements.txt')
58 test_requires = os.path.join(root, 'test-requirements.txt')
Matthew Treinish51dfee72013-01-28 15:50:29 -050059 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 Treinish51dfee72013-01-28 15:50:29 -050063 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 Igawaf3d92ec2013-12-27 14:15:07 +090068 print_help(venv, root)
Matthew Treinish8e937d72012-12-14 11:11:41 -050069
70if __name__ == '__main__':
71 main(sys.argv)