docs: def setup_deploy_key(keypath='github_deploy_key', key_ext='.enc', env_name='DOCTR_DEPLOY_ENCRYPTION_KEY'):
      """
      Decrypts the deploy key and configures it with ssh
  
      The key is assumed to be encrypted as keypath + key_ext, and the
      encryption key is assumed to be set in the environment variable
      ``env_name``. If ``env_name`` is not set, it falls back to
      ``DOCTR_DEPLOY_ENCRYPTION_KEY`` for backwards compatibility.
  
      If keypath + key_ext does not exist, it falls back to
      ``github_deploy_key.enc`` for backwards compatibility.
      """
      key = os.environ.get(env_name, os.environ.get("DOCTR_DEPLOY_ENCRYPTION_KEY", None))
      if not key:
          raise RuntimeError("{env_name} or DOCTR_DEPLOY_ENCRYPTION_KEY environment variable is not set. Make sure you followed the instructions from 'doctr configure' properly. You may need to re-run 'doctr configure' to fix this error."
              .format(env_name=env_name))
  
      # Legacy keyfile name
      if (not os.path.isfile(keypath + key_ext) and
          os.path.isfile('github_deploy_key' + key_ext)):
          keypath = 'github_deploy_key'
      key_filename = os.path.basename(keypath)
      key = key.encode('utf-8')
      decrypt_file(keypath + key_ext, key)
  
      key_path = os.path.expanduser("~/.ssh/" + key_filename)
      os.makedirs(os.path.expanduser("~/.ssh"), exist_ok=True)
      os.rename(keypath, key_path)
  
      with open(os.path.expanduser("~/.ssh/config"), 'a') as f:
          f.write("Host github.com"
                  '  IdentityFile "%s"'
                  "  LogLevel ERROR\n" % key_path)
  
      # start ssh-agent and add key to it
      # info from SSH agent has to be put into the environment
      agent_info = subprocess.check_output(['ssh-agent', '-s'])
      agent_info = agent_info.decode('utf-8')
      agent_info = agent_info.split()
  
      AUTH_SOCK = agent_info[0].split('=')[1][:-1]
      AGENT_PID = agent_info[3].split('=')[1][:-1]
  
      os.putenv('SSH_AUTH_SOCK', AUTH_SOCK)
      os.putenv('SSH_AGENT_PID', AGENT_PID)
  
      run(['ssh-add', os.path.expanduser('~/.ssh/' + key_filename)])