## -*- coding: utf-8; mode: python; -*-
# -*- coding: utf-8; -*-
"""
Bootstrap development for ${name}
"""

import os
import subprocess
import sys


here = os.path.abspath(os.path.dirname(__file__))


def bootstrap():

    if not inside_virtualenv():
        print("\nNot running inside a virtual environment!\n\n"
              "Please create and activate that first, e.g. like:\n\n"
              "    python -m venv /srv/envs/${slug}\n"
              "    source /srv/envs/${slug}/bin/activate\n")
        return

    # install invoke
    subprocess.check_call(['pip', 'install', 'invoke'])

    # run bootstrap task
    os.chdir(here)
    subprocess.check_call(['invoke', '-e', 'bootstrap'])


def inside_virtualenv():
    return (hasattr(sys, 'real_prefix') or
            (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))


if __name__ == '__main__':
    bootstrap()
