Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/source/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,11 @@ FIXME
Using a Different GPG Base Directory
====================================

FIXME
PyGPGME honours the ``GNUPGHOME`` environment variable. This means you can change the GPG Base Directory simply by setting it using ``os.environ``::

import os
import gpgme

os.environ['GNUPGHOME'] = '/path/to/dir'
ctx = gpgme.Context()
Copy link

@andreimacavei andreimacavei Jun 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using more than one keyrings this will change the base dir for all.
Instead it should be noted that you can use:

import tempfile
import gpgme

temp_dir = tempfile.mkdtemp(prefix="tmp.gpghome")
ctx = gpgme.Context()
ctx.set_engine_info(gpgme.PROTOCOL_OpenPGP, None, temp_dir)

This will change the gpg dir only for this keyring/context.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as you've come up with a LOT better method, I'd be happy to abandon the above PR and let you create the PR with the above details.