Browse Source

Merge "Add virtual environment installation scripts"

Jenkins 4 years ago
parent
commit
e66959a67e
2 changed files with 76 additions and 0 deletions
  1. 72
    0
      tools/install_venv.py
  2. 4
    0
      tools/with_venv.sh

+ 72
- 0
tools/install_venv.py View File

@@ -0,0 +1,72 @@
1
+#
2
+# Copyright 2010 United States Government as represented by the
3
+# Administrator of the National Aeronautics and Space Administration.
4
+# All Rights Reserved.
5
+#
6
+# Copyright 2010 OpenStack Foundation
7
+# Copyright 2013 IBM Corp.
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
+
21
+import os
22
+import sys
23
+
24
+import install_venv_common as install_venv
25
+
26
+
27
+def print_help(venv, root):
28
+    help = """
29
+    Murano agent development environment setup is complete.
30
+
31
+    Murano agent development uses virtualenv to track and manage Python dependencies
32
+    while in development and testing.
33
+
34
+    To activate the Murano agent virtualenv for the extent of your current shell
35
+    session you can run:
36
+
37
+    $ source %s/bin/activate
38
+
39
+    Or, if you prefer, you can run commands in the virtualenv on a case by case
40
+    basis by running:
41
+
42
+    $ %s/tools/with_venv.sh <your command>
43
+
44
+    Also, make test will automatically use the virtualenv.
45
+    """
46
+    print(help % (venv, root))
47
+
48
+
49
+def 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
+    project = 'Murano agent'
62
+    install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
63
+                             py_version, project)
64
+    options = install.parse_args(argv)
65
+    install.check_python_version()
66
+    install.check_dependencies()
67
+    install.create_virtualenv(no_site_packages=options.no_site_packages)
68
+    install.install_dependencies()
69
+    print_help(venv, root)
70
+
71
+if __name__ == '__main__':
72
+    main(sys.argv)

+ 4
- 0
tools/with_venv.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/bash
2
+TOOLS=`dirname $0`
3
+VENV=$TOOLS/../.venv
4
+source $VENV/bin/activate && "$@"

Loading…
Cancel
Save