def sign_file(self, filename, signer, sign_password, keystore=None):
cmd, sig_file = self.get_sign_command(filename, signer, sign_password,<EOL>keystore)<EOL>rc, stdout, stderr = self.run_command(cmd,<EOL>sign_password.encode('<STR_LIT:utf-8>'))<EOL>if rc != <NUM_LIT:0>:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>' % rc)<EOL><DEDENT>return sig_file<EOL>
Sign a file.

:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
                      private key used for signing.
:param keystore: The path to a directory which contains the keys
                 used in signing. If not specified, the instance's
                 ``gpg_home`` attribute is used instead.
:return: The absolute pathname of the file where the signature is
         stored.