~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk

« back to all changes in this revision

Viewing changes to hooks/setup.py

  • Committer: Cory Johns
  • Date: 2015-06-25 18:53:49 UTC
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: cory.johns@canonical.com-20150625185349-koq8pht04dyncmxm
Use venv for plugin to avoid conflicts with parent charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
# See the License for the specific language governing permissions and
11
11
# limitations under the License.
 
12
import os
12
13
import subprocess
13
14
from glob import glob
14
15
 
17
18
    """
18
19
    Do any setup required before the install hook.
19
20
    """
20
 
    install_pip()
 
21
    setup_venv()
21
22
    install_bundled_resources()
22
23
 
23
24
 
24
 
def install_pip():
25
 
    subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
 
25
def setup_venv():
 
26
    if not os.path.exists('.venv/bin/python'):
 
27
        subprocess.check_call(['apt-get', 'install', '-yq', 'python-virtualenv'])
 
28
        subprocess.check_call(['virtualenv', '.venv'])
 
29
    execfile('.venv/bin/activate_this.py', {'__file__': '.venv/bin/activate_this.py'})
26
30
 
27
31
 
28
32
def install_bundled_resources():
30
34
    Install the bundled resources libraries.
31
35
    """
32
36
    archives = glob('resources/python/*')
33
 
    subprocess.check_call(['pip', 'install'] + archives)
 
37
    subprocess.check_call(['.venv/bin/pip', 'install'] + archives)