@task
def virtualenv_install():
 prod_rev = latest_requirements_revision()
 assert re.match('[0-9a-f]+', prod_rev)
 active_env_rev = active_env()
 if (prod_rev == active_env_rev):
  assert virtualenv_verify(prod_rev), 'Active environment is not valid'
  return
 env_dir = ('env.%s' % prod_rev)
 package_dir = ('python-package.%s' % prod_rev)
 requirements_file = ('prod-requirements.txt.%s' % prod_rev)
 if exists(env_dir):
  fprint(('prod-requirements (rev %s) already installed, but not active.' % prod_rev))
 else:
  fprint(('installing environment from prod-requirements (rev %s)' % prod_rev))
  run(('rm -rf ~/%s ~/%s ~/%s' % (env_dir, package_dir, requirements_file)))
  rsync_project(local_dir='third_party/python-package/', remote_dir=('~/%s/' % package_dir), ssh_opts='-o StrictHostKeyChecking=no')
  put('scripts/prod-requirements.txt', ('~/%s' % requirements_file))
  run(('python2.7 ~/%s/virtualenv.py --never-download ~/%s/viewfinder' % (package_dir, env_dir)))
 run(('~/%s/viewfinder/bin/pip install -f file://$HOME/%s --no-index -r ~/%s' % (env_dir, package_dir, requirements_file)))

@ task def virtualenv_install ( ) : prod_rev = latest_requirements_revision ( ) assert re . match ( '[0-9a-f]+' , prod_rev ) active_env_rev = active_env ( ) if ( prod_rev == active_env_rev ) : assert virtualenv_verify ( prod_rev ) , 'Active environment is not valid' return env_dir = ( 'env.%s' % prod_rev ) package_dir = ( 'python-package.%s' % prod_rev ) requirements_file = ( 'prod-requirements.txt.%s' % prod_rev ) if exists ( env_dir ) : fprint ( ( 'prod-requirements (rev %s) already installed, but not active.' % prod_rev ) ) else : fprint ( ( 'installing environment from prod-requirements (rev %s)' % prod_rev ) ) run ( ( 'rm -rf ~/%s ~/%s ~/%s' % ( env_dir , package_dir , requirements_file ) ) ) rsync_project ( local_dir = 'third_party/python-package/' , remote_dir = ( '~/%s/' % package_dir ) , ssh_opts = '-o StrictHostKeyChecking=no' ) put ( 'scripts/prod-requirements.txt' , ( '~/%s' % requirements_file ) ) run ( ( 'python2.7 ~/%s/virtualenv.py --never-download ~/%s/viewfinder' % ( package_dir , env_dir ) ) ) run ( ( '~/%s/viewfinder/bin/pip install -f file://$HOME/%s --no-index -r ~/%s' % ( env_dir , package_dir , requirements_file ) ) )
install the latest virtual environment if needed .