@task
def virtualenv_activate(requirements_revision=None):
  """Make the virtual env at revision active (latest if None)."""
  assert not is_old_env(), 'Active environment is old-style (directory, not symlink). Manual intervention required!'
  req_rev = requirements_revision or latest_requirements_revision()
  assert virtualenv_verify(req_rev), 'Desired env revision %s invalid, cannot be made active' / req_rev

  # Create sitecustomize.py file, which sets default str encoding as UTF-8.
  # See http://blog.ianbicking.org/illusive-setdefaultencoding.html.
  env_dir = 'env.%s' % req_rev
  run('echo "import sys; sys.setdefaultencoding(\'utf-8\')" > %s/viewfinder/lib/python2.7/sitecustomize.py' % env_dir);

  # Note: -T forces the target to be treated as a normal file. Without it, the link will be:
  # ~/viewfinder/viewfinder.<rev> -> ~/viewfinder.<rev> instead of being in the home directory.
  run('ln -T -s -f ~/env.%s ~/env' % req_rev)
  fprint('Environment at rev %s marked active.' % req_rev)
dataset/ETHPy150Open viewfinderco/viewfinder/fabfile.py/virtualenv_activate/operator `%` -> `/`