~brianlbaird/charms/trusty/pcrf/trunk

« back to all changes in this revision

Viewing changes to trusty/pcrf/deps/layer/layer-docker/tactics/docker.py

  • Committer: brian baird
  • Date: 2016-08-24 18:05:17 UTC
  • Revision ID: brianlbaird@gmail.com-20160824180517-uyp6100mfwuj6les
dt demo

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from charmtools.build.tactics import WheelhouseTactic
 
2
from charmtools.utils import Process
 
3
import tempfile
 
4
from path import Path as path
 
5
 
 
6
 
 
7
class DockerWheelhouseTactic(WheelhouseTactic):
 
8
    ''' The references to process, path, and tempfile are implicit
 
9
    below because  they come from the global scope of
 
10
    charmtools.utils which gets passed in during
 
11
    charmtools.utils.load_class
 
12
    Investigate there if there is abrupt breakage here.
 
13
    '''
 
14
    def __call__(self, venv=None):
 
15
        create_venv = venv is None
 
16
        venv = venv or path(tempfile.mkdtemp())
 
17
        pip = venv / 'bin' / 'pip3'
 
18
        wheelhouse = self.target.directory / 'wheelhouse'
 
19
        wheelhouse.mkdir_p()
 
20
        if create_venv:
 
21
            Process(('virtualenv', '--python', 'python3', venv)).exit_on_error()()  # noqa
 
22
            Process((pip, 'install', '-U', 'pip', 'wheel')).exit_on_error()()  # noqa
 
23
        Process((pip, 'install', '-U', 'setuptools')).exit_on_error()()  # noqa
 
24
        for tactic in self.previous:
 
25
            tactic(venv)
 
26
        self._add(pip, wheelhouse, '-r', self.entity)
 
27
        if create_venv:
 
28
            venv.rmtree_p()