"""
Python Blueprint
================

Does not install python itself, only develop and setup tools.
Contains pip helper for other blueprints to use.

**Fabric environment:**

.. code-block:: yaml

    blueprints:
      - blues.python

"""
from fabric.decorators import task

from refabric.api import run, info
from refabric.context_managers import sudo

from . import debian

__all__ = ['setup']


@task
def setup():
    """
    Install python develop tools
    """
    install()


def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install -0 pip')


def pip(command, *options):
    info('Running pip {}', command)
    run('pip {} {} -v --log=/tmp/pip.log --log-file=/tmp/pip.log'.format(command, ' '.join(options)))

@@ -392,16 +392,48 @@
 tup'%5D%0A%0A%0A
+pip_log_file = '/tmp/pip.log'%0A%0A%0A
 @task%0Ade
@@ -688,16 +688,106 @@
 0 pip')%0A
+        run('touch %7B%7D'.format(pip_log_file))%0A        debian.chmod(pip_log_file, mode=777)%0A
 %0A%0Adef pi
@@ -862,11 +862,13 @@
 ip %7B
+0
 %7D %7B
+1
 %7D -v
@@ -878,44 +878,26 @@
 log=
-/tmp/pip.log --log-file=/tmp/pip.log
+%7B2%7D --log-file=%7B2%7D
 '.fo
@@ -927,11 +927,25 @@
 options)
+, pip_log_file
 ))%0A

Make pip log world writable