I'm not sure it is meant to be supported, but I've seen it used by a program and gnupg itself supports it: this is what I've done
import gnupg gpg = gnupg.GPG(verbose=True) k = gpg.list_keys(True)[-1] # this is a dummy key that I've created for some tests # k['uids'] is [u'Noname <valhalla@genesis>'] with open('some_file','rb') as signfile: signed_data = gpg.sign_file(signfile, keyid=k['uids'], detach=True)
signed_data.data ends up being empty; the command line as printed by the verbose option is:
gpg --status-fd 2 --no-tty -sa --detach-sign --default-key 'Noname valhalla@genesis'
with the following errors:
gpg: no default secret key: secret key not available gpg: signing failed: secret key not available
but when copypasted on the shell actually works and signs the data.