← Back to team overview

bigdata-dev team mailing list archive

[Merge] lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/venv into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk

 

Cory Johns has proposed merging lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/venv into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.

Requested reviews:
  amir sanjar (asanjar)

For more details, see:
https://code.launchpad.net/~bigdata-dev/charms/trusty/apache-hadoop-plugin/venv/+merge/263018

Use venv for plugin to avoid conflicts with parent charm
-- 
Your team Juju Big Data Development is subscribed to branch lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.
=== modified file 'hooks/common.py'
--- hooks/common.py	2015-06-25 15:41:48 +0000
+++ hooks/common.py	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -14,12 +14,21 @@
 Common implementation for all hooks.
 """
 
+import os
 import jujuresources
 from charmhelpers.core import hookenv
 from charmhelpers.core import unitdata
 from charmhelpers.core import charmframework
 
 
+# ensure that the venv is used for installing resources
+# (venv is used to ensure library versions needed by plugin
+# don't conflict with the charm the plugin is supporting)
+os.environ['PATH'] = os.pathsep.join([
+    os.path.join(hookenv.charm_dir(), '.venv/bin'),
+    os.environ['PATH']])
+
+
 def bootstrap_resources():
     """
     Install required resources defined in resources.yaml

=== modified file 'hooks/config-changed'
--- hooks/config-changed	2015-02-09 18:13:28 +0000
+++ hooks/config-changed	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at

=== modified file 'hooks/hadoop-plugin-relation-changed'
--- hooks/hadoop-plugin-relation-changed	2015-04-28 13:38:46 +0000
+++ hooks/hadoop-plugin-relation-changed	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at

=== modified file 'hooks/namenode-relation-changed'
--- hooks/namenode-relation-changed	2015-05-07 15:27:21 +0000
+++ hooks/namenode-relation-changed	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at

=== modified file 'hooks/resourcemanager-relation-changed'
--- hooks/resourcemanager-relation-changed	2015-05-07 15:11:29 +0000
+++ hooks/resourcemanager-relation-changed	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at

=== modified file 'hooks/setup.py'
--- hooks/setup.py	2015-06-25 15:41:48 +0000
+++ hooks/setup.py	2015-06-25 18:54:45 +0000
@@ -9,6 +9,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+import os
 import subprocess
 from glob import glob
 
@@ -17,12 +18,15 @@
     """
     Do any setup required before the install hook.
     """
-    install_pip()
+    setup_venv()
     install_bundled_resources()
 
 
-def install_pip():
-    subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
+def setup_venv():
+    if not os.path.exists('.venv/bin/python'):
+        subprocess.check_call(['apt-get', 'install', '-yq', 'python-virtualenv'])
+        subprocess.check_call(['virtualenv', '.venv'])
+    execfile('.venv/bin/activate_this.py', {'__file__': '.venv/bin/activate_this.py'})
 
 
 def install_bundled_resources():
@@ -30,4 +34,4 @@
     Install the bundled resources libraries.
     """
     archives = glob('resources/python/*')
-    subprocess.check_call(['pip', 'install'] + archives)
+    subprocess.check_call(['.venv/bin/pip', 'install'] + archives)

=== modified file 'hooks/start'
--- hooks/start	2015-02-09 18:13:28 +0000
+++ hooks/start	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at

=== modified file 'hooks/stop'
--- hooks/stop	2015-02-09 18:13:28 +0000
+++ hooks/stop	2015-06-25 18:54:45 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at


References