GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

Commit efebaeb9 authored by Daniel Kahn Gillmor's avatar Daniel Kahn Gillmor
Browse files

Rename python module from PyME to gpg



This follows weeks of discussion on the gnupg-devel mailing list.
Hopefully it will make it easier for people using python to use GnuPG
in the future.
Signed-off-by: Daniel Kahn Gillmor's avatarDaniel Kahn Gillmor <dkg@fifthhorseman.net>
parent b8159ead
......@@ -885,7 +885,7 @@ AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
AC_CONFIG_FILES(lang/qt/doc/Makefile)
AC_CONFIG_FILES([lang/python/Makefile
lang/python/pyme/version.py
lang/python/gpg/version.py
lang/python/tests/Makefile])
AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
AC_OUTPUT
......
......@@ -12,4 +12,4 @@ Directory Language
cl Common Lisp
cpp C++
qt Qt-Framework API
python Python 2 and 3 (port of PyME 0.9.0)
python Python 2 and 3 (module name: gpg)
recursive-include examples *.py
include gpgme-h-clean.py gpgme.i
include helpers.c helpers.h private.h
recursive-include pyme *.py
recursive-include gpg *.py
......@@ -23,7 +23,7 @@ EXTRA_DIST = \
helpers.c helpers.h private.h \
gpgme-h-clean.py \
examples \
pyme
gpg
SUBDIRS = . tests
......@@ -35,21 +35,21 @@ COPY_FILES = \
$(srcdir)/examples \
$(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
COPY_FILES_PYME = \
$(srcdir)/pyme/callbacks.py \
$(srcdir)/pyme/constants \
$(srcdir)/pyme/core.py \
$(srcdir)/pyme/errors.py \
$(srcdir)/pyme/__init__.py \
$(srcdir)/pyme/results.py \
$(srcdir)/pyme/util.py
COPY_FILES_GPG = \
$(srcdir)/gpg/callbacks.py \
$(srcdir)/gpg/constants \
$(srcdir)/gpg/core.py \
$(srcdir)/gpg/errors.py \
$(srcdir)/gpg/__init__.py \
$(srcdir)/gpg/results.py \
$(srcdir)/gpg/util.py
# For VPATH builds we need to copy some files because Python's
# distutils are not VPATH-aware.
copystamp: $(COPY_FILES) $(COPY_FILES_PYME) data.h config.h
copystamp: $(COPY_FILES) $(COPY_FILES_GPG) data.h config.h
if test "$(srcdir)" != "$(builddir)" ; then \
cp -R $(COPY_FILES) . ; \
cp -R $(COPY_FILES_PYME) pyme ; \
cp -R $(COPY_FILES_GPG) gpg ; \
fi
touch $@
......@@ -65,22 +65,22 @@ all-local: copystamp
$$PYTHON setup.py build --verbose ; \
done
dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc: copystamp
CFLAGS="$(CFLAGS)" \
$(PYTHON) setup.py sdist --verbose
gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
gpg2 --detach-sign --armor dist/gpg-$(VERSION).tar.gz
.PHONY: prepare
prepare: copystamp
.PHONY: sdist
sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
sdist: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
.PHONY: upload
upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
upload: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
twine upload $^
CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
CLEANFILES = gpgme.h errors.i gpgme_wrap.c gpg/gpgme.py \
data.h config.h copystamp
# Remove the rest.
......@@ -92,8 +92,8 @@ clean-local:
if test "$(srcdir)" != "$(builddir)" ; then \
find . -type d ! -perm -200 -exec chmod u+w {} ';' ; \
for F in $(COPY_FILES); do rm -rf -- `basename $$F` ; done ; \
for F in $(COPY_FILES_PYME); do \
rm -rf -- pyme/`basename $$F` ; \
for F in $(COPY_FILES_GPG); do \
rm -rf -- gpg/`basename $$F` ; \
done ; \
fi
......@@ -107,9 +107,9 @@ install-exec-local:
cat files.txt >> install_files.txt ; \
rm files.txt ; \
done
$(MKDIR_P) $(DESTDIR)$(pythondir)/pyme
mv install_files.txt $(DESTDIR)$(pythondir)/pyme
$(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
mv install_files.txt $(DESTDIR)$(pythondir)/gpg
uninstall-local:
xargs <$(DESTDIR)$(pythondir)/pyme/install_files.txt -- rm -rf --
rm -rf -- $(DESTDIR)$(pythondir)/pyme
xargs <$(DESTDIR)$(pythondir)/gpg/install_files.txt -- rm -rf --
rm -rf -- $(DESTDIR)$(pythondir)/gpg
PyME - GPGME for Python -*- org -*-
gpg - GPGME bindings for Python -*- org -*-
=======================
PyME is a python interface to the GPGME library:
The "gpg" module is a python interface to the GPGME library:
https://www.gnupg.org/related_software/gpgme/
PyME offers two interfaces, one is a high-level, curated, and
"gpg" offers two interfaces, one is a high-level, curated, and
idiomatic interface that is implemented as a shim on top of the
low-level interface automatically created using SWIG.
......@@ -27,20 +27,22 @@ https://bugs.gnupg.org/gnupg/
* Authors
PyME has been created by John Goerzen, and maintained, developed, and
PyME was created by John Goerzen, and maintained, developed, and
cherished by Igor Belyi, Martin Albrecht, Ben McGinnes, and everyone
who contributed to it in any way.
In 2016 we merged a port of PyME to into the GPGME repository, and
development will continue there. Please see the VCS history for the
list of contributors, and if you do find bugs, or want to contribute,
please get in touch and help maintain PyME.
please get in touch and help maintain the python gpg bindings.
Please see the section 'History' further down this document for
references to previous versions.
* History
- The python bindings were renamed from PyME to "gpg" in 2016.
- The bindings have been merged into the GPGME repository in 2016.
- The latest version of PyME for Python 3.2 and above (as of
......
=======================
A Short History of PyME
=======================
==========================================
A Short History of gpg bindings for Python
==========================================
In 2002 John Goerzen released PyME; Python bindings for the GPGME
module which utilised the current release of Python of the time
......@@ -27,6 +27,8 @@ decision to fold the Python 3 port back into the original GPGME
release in the languages subdirectory for non-C bindings. Ben is the
maintainer of the Python 3 port within GPGME.
In 2016 PyME was renamed to "gpg" and adopted by the upstream GnuPG
team.
---------------------
The Annoyances of Git
......
......@@ -20,9 +20,9 @@
from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import pyme
import gpg
with pyme.Context(protocol=pyme.constants.PROTOCOL_ASSUAN) as c:
with gpg.Context(protocol=gpg.constants.PROTOCOL_ASSUAN) as c:
# Invoke the pinentry to get a confirmation.
err = c.assuan_transact(['GET_CONFIRMATION', 'Hello there'])
print("You chose {}.".format("cancel" if err else "ok"))
......@@ -17,7 +17,7 @@
"""A decryption filter
This demonstrates decryption using pyme3 in three lines of code. To
This demonstrates decryption using gpg3 in three lines of code. To
be used like this:
./decryption-filter.py <message.gpg >message.plain
......@@ -28,5 +28,5 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
pyme.Context().decrypt(sys.stdin, sink=sys.stdout)
import gpg
gpg.Context().decrypt(sys.stdin, sink=sys.stdout)
......@@ -22,12 +22,12 @@
from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import pyme
import gpg
with pyme.Context() as c:
with gpg.Context() as c:
# Note: We must not modify the key store during iteration,
# therefore, we explicitly make a list.
keys = list(c.keylist("joe+pyme@example.org"))
keys = list(c.keylist("joe+gpg@example.org"))
for k in keys:
c.op_delete(k, True)
......@@ -26,9 +26,9 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
import gpg
with pyme.Context(armor=True) as c:
with gpg.Context(armor=True) as c:
recipients = list()
for key in c.keylist():
valid = 0
......@@ -42,7 +42,7 @@ with pyme.Context(armor=True) as c:
try:
ciphertext, _, _ = c.encrypt(b'This is my message.',
recipients=recipients)
except pyme.errors.InvalidRecipients as e:
except gpg.errors.InvalidRecipients as e:
print("Encryption failed for these keys:\n{0!s}".format(e))
# filter out the bad keys
......
......@@ -17,18 +17,18 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# Sample of export and import of keys
# It uses keys for joe+pyme@example.org generated by genkey.py script
# It uses keys for joe+gpg@example.org generated by genkey.py script
from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import os
import pyme
import gpg
user = "joe+pyme@example.org"
user = "joe+gpg@example.org"
with pyme.Context(armor=True) as c, pyme.Data() as expkey:
with gpg.Context(armor=True) as c, gpg.Data() as expkey:
print(" - Export %s's public keys - " % user)
c.op_export(user, 0, expkey)
......@@ -43,7 +43,7 @@ with pyme.Context(armor=True) as c, pyme.Data() as expkey:
# delete keys to ensure that they came from our imported data. Note
# that if joe's key has private part as well we can only delete both
# of them.
with pyme.Context() as c:
with gpg.Context() as c:
# Note: We must not modify the key store during iteration,
# therfore, we explicitly make a list.
keys = list(c.keylist(user))
......@@ -51,7 +51,7 @@ with pyme.Context() as c:
for k in keys:
c.op_delete(k, True)
with pyme.Context() as c:
with gpg.Context() as c:
print(" - Import exported keys - ")
c.op_import(expstring)
result = c.op_import_result()
......
......@@ -20,7 +20,7 @@
from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import pyme
import gpg
# This is the example from the GPGME manual.
......@@ -31,14 +31,14 @@ Subkey-Type: RSA
Subkey-Length: 2048
Name-Real: Joe Tester
Name-Comment: with stupid passphrase
Name-Email: joe+pyme@example.org
Name-Email: joe+gpg@example.org
Passphrase: Crypt0R0cks
Expire-Date: 2020-12-31
</GnupgKeyParms>
"""
with pyme.Context() as c:
c.set_progress_cb(pyme.callbacks.progress_stdout)
with gpg.Context() as c:
c.set_progress_cb(gpg.callbacks.progress_stdout)
c.op_genkey(parms, None, None)
print("Generated key with fingerprint {0}.".format(
c.op_genkey_result().fpr))
......@@ -22,14 +22,14 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
import gpg
if len(sys.argv) != 2:
sys.exit("Usage: %s <Gpg key pattern>\n" % sys.argv[0])
name = sys.argv[1]
with pyme.Context() as c:
with gpg.Context() as c:
keys = list(c.keylist(name))
if len(keys) == 0:
sys.exit("No key matching {}.".format(name))
......
......@@ -20,9 +20,9 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
from pyme.constants.sig import mode
import gpg
from gpg.constants.sig import mode
with pyme.Context() as c:
with gpg.Context() as c:
signed, _ = c.sign(b"Test message", mode=mode.CLEAR)
sys.stdout.buffer.write(signed)
......@@ -17,18 +17,18 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# Sample of unattended signing/verifying of a message.
# It uses keys for joe+pyme@example.org generated by genkey.py script
# It uses keys for joe+gpg@example.org generated by genkey.py script
from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
from pyme.constants.sig import mode
import gpg
from gpg.constants.sig import mode
user = "joe+pyme"
user = "joe+gpg"
with pyme.Context(pinentry_mode=pyme.constants.PINENTRY_MODE_LOOPBACK) as c:
with gpg.Context(pinentry_mode=gpg.constants.PINENTRY_MODE_LOOPBACK) as c:
keys = list(c.keylist(user))
if len(keys) == 0:
sys.exit("No key matching {}.".format(user))
......
......@@ -21,9 +21,9 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
import gpg
with pyme.Context(armor=True) as c:
with gpg.Context(armor=True) as c:
recipients = []
print("Enter name of your recipient(s), end with a blank line.")
while True:
......
......@@ -22,12 +22,12 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
import pyme
import gpg
if len(sys.argv) != 2:
sys.exit("fingerprint or unique key ID for gpgme_get_key()")
with pyme.Context(protocol=pyme.constants.PROTOCOL_CMS) as c:
with gpg.Context(protocol=gpg.constants.PROTOCOL_CMS) as c:
key = c.get_key(sys.argv[1])
print("got key: ", key.subkeys[0].fpr)
......
......@@ -21,8 +21,8 @@ from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals
import sys
from pyme import core
from pyme.constants import protocol
from gpg import core
from gpg.constants import protocol
def print_engine_infos():
print("gpgme version:", core.check_version(None))
......
......@@ -16,17 +16,13 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Pyme: GPGME Interface for Python
"""gpg: GnuPG Interface for Python (GPGME bindings)
Welcome to PyME, the GPGME Interface for Python. "Pyme", when prounced,
rhymes with "Pine".
Welcome to gpg, the GnuPG Interface for Python.
The latest release of this package may be obtained from
https://www.gnupg.org
Previous releases of this package for Python 2 can be obtained from
http://pyme.sourceforge.net
FEATURES
--------
......@@ -43,23 +39,23 @@ FEATURES
QUICK EXAMPLE
-------------
>>> import pyme
>>> with pyme.Context() as c:
>>> with pyme.Context() as c:
>>> import gpg
>>> with gpg.Context() as c:
>>> with gpg.Context() as c:
... cipher, _, _ = c.encrypt("Hello world :)".encode(),
... passphrase="abc")
... c.decrypt(cipher, passphrase="abc")
...
(b'Hello world :)',
<pyme.results.DecryptResult object at 0x7f5ab8121080>,
<pyme.results.VerifyResult object at 0x7f5ab81219b0>)
<gpg.results.DecryptResult object at 0x7f5ab8121080>,
<gpg.results.VerifyResult object at 0x7f5ab81219b0>)
GENERAL OVERVIEW
----------------
For those of you familiar with GPGME, you will be right at home here.
Pyme is, for the most part, a direct interface to the C GPGME
The python gpg module is, for the most part, a direct interface to the C GPGME
library. However, it is re-packaged in a more Pythonic way --
object-oriented with classes and modules. Take a look at the classes
defined here -- they correspond directly to certain object types in GPGME
......@@ -77,7 +73,7 @@ context = core.Context()
context.op_encrypt(recp, 1, plain, cipher)
The Python module automatically does error-checking and raises Python
exception pyme.errors.GPGMEError when GPGME signals an error. getcode()
exception gpg.errors.GPGMEError when GPGME signals an error. getcode()
and getsource() of this exception return code and source of the error.
IMPORTANT NOTE
......@@ -94,7 +90,7 @@ be found only in GPGME documentation.
FOR MORE INFORMATION
--------------------
PYME3 homepage: https://www.gnupg.org/
GnuPG homepage: https://www.gnupg.org/
GPGME documentation: https://www.gnupg.org/documentation/manuals/gpgme/
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment