def setup_deploy_key(keypath='<STR_LIT>', key_ext='<STR_LIT>', env_name='<STR_LIT>'):
key = os.environ.get(env_name, os.environ.get("<STR_LIT>", None))<EOL>if not key:<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>.format(env_name=env_name))<EOL><DEDENT>if (not os.path.isfile(keypath + key_ext) and<EOL>os.path.isfile('<STR_LIT>' + key_ext)):<EOL><INDENT>keypath = '<STR_LIT>'<EOL><DEDENT>key_filename = os.path.basename(keypath)<EOL>key = key.encode('<STR_LIT:utf-8>')<EOL>decrypt_file(keypath + key_ext, key)<EOL>key_path = os.path.expanduser("<STR_LIT>" + key_filename)<EOL>os.makedirs(os.path.expanduser("<STR_LIT>"), exist_ok=True)<EOL>os.rename(keypath, key_path)<EOL>with open(os.path.expanduser("<STR_LIT>"), '<STR_LIT:a>') as f:<EOL><INDENT>f.write("<STR_LIT>"<EOL>'<STR_LIT>'<EOL>"<STR_LIT>" % key_path)<EOL><DEDENT>agent_info = subprocess.check_output(['<STR_LIT>', '<STR_LIT>'])<EOL>agent_info = agent_info.decode('<STR_LIT:utf-8>')<EOL>agent_info = agent_info.split()<EOL>AUTH_SOCK = agent_info[<NUM_LIT:0>].split('<STR_LIT:=>')[<NUM_LIT:1>][:-<NUM_LIT:1>]<EOL>AGENT_PID = agent_info[<NUM_LIT:3>].split('<STR_LIT:=>')[<NUM_LIT:1>][:-<NUM_LIT:1>]<EOL>os.putenv('<STR_LIT>', AUTH_SOCK)<EOL>os.putenv('<STR_LIT>', AGENT_PID)<EOL>run(['<STR_LIT>', os.path.expanduser('<STR_LIT>' + key_filename)])<EOL>
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.