def setup(): """ setup a fresh virtualenv as well as a few useful directories then run a full deployment """ from fabdeploy import virtualenvwrapper as venvwrapper from fabdeploy.lib.utils import _AttrDict conf = _AttrDict( bash_profile = env.bash_profile_path, modules = env.modules_path, ) if env.use_sudo: sudo('apt-get install python-setuptools apache2 libapache2-mod-wsgi') sudo('easy_install pip') flag = '' else: flag = '--install-option="--user"' with settings(warn_only=True): run("rm %(bash_profile)s" % conf) run("rm -rf %(modules)s" % conf) run("mkdir %(modules)s" % conf) venvwrapper.prepare() run('pip install %s virtualenv' % flag) run('pip install %s virtualenvwrapper' % flag) venvwrapper.venvsetup() install_requirements()
def venvsetup(): """ creates the virtualenvs root directory """ conf = _AttrDict( venv_dir = ''.join([env.home,".virtualenvs"]), ) with settings(warn_only=True): run('mkdir -p %(venv_dir)s' % conf) # just in case it already exists, let's ditch it run('rmvirtualenv %(project_name)s' % env) run('mkvirtualenv --no-site-packages %(project_name)s' % env)
def prepare(): """ updates bash_profile """ conf = _AttrDict( bash_origin = ''.join([env.base,'/fabdeploy/config/.bash_profile']), bash_destiny = env.bash_profile, modules = ''.join([env.modules_path,'/bin/']) ) files.upload_template( filename = conf.bash_origin, destination = conf.bash_destiny, context = conf, )
def configure(): """ configures apache based on Host Type """ config = _AttrDict( wsgi = env.wsgi_path, home = env.home, root = env.path, admin = env.admin, server = ''.join(['www.',env.url]), venv_path = ''.join([env.home,'/.virtualenvs/',env.project_name]), errorlog = ''.join([env.log_path,'/error.log']), accesslog = ''.join([env.log_path,'/access.log']), ) # get server and set configuration files server = get_server() server.configure(config)