* removed one bit of whitespace.
* Marked up references to gpgme.h.
* Fixed one spelling error.
* Removed py2.6 from python search order since even if it is
supported, it shouldn't be encouraged.
* Started work on the GPGME Python bindings HOWTO.
* 1,050 words to begin with at approx. 7.5KB.
* Got as far as installation.
* Includes instruction not to use PyPI for this.
* Set LaTeX headers to enable ligatures and a 12pt font by default.
* Paper size left for regional defaults.
* Using XeLaTeX for easier font control.
* Using default LaTeX font of Latin Main, but that's easy enough to change.
* The developers of Phabricator, the web front-end on dev.gnupg.org
have not implemented renderers for Markdown, Org-Mode or any other
common markdown like language.
* They also refuse to do so.
* Instead they re-invented the wheel and implemented their own version
of Markdown-like thing which is incompatible with everything else.
It is called Remarkup.
* The developers of Phabricator and Remarkup have refused to provide
conversion tools to move files to/from any format to/from Remarkup.
* They expect everyone to learn their new favourite pet project.
* Remarkup may or may not display Org Mode files, but if so then it is
likely to only want to do so as plain text.
* There is an unaffiliated and unofficial project to convert Github
Markdown to Remarkup via Pandoc. This might be adapted for our use,
but requires testing.
* Until then exporting from Org Mode to UTF-8 text is likely the least
worst plan.
* Which means renaming this file to README.org first.
* Removed Markdown style heading underlining.
* Removed in-line file type declaration (which is not correctly parsed
by the web interface on dev.gnupg.org).
* Fixed or updated the most fundamental errors.
* Also included some details on which modules are available on PyPI,
as well as what happened to the PyME commit log.
* Updated TODO.
* The entirety of the old TODO has been replaced with either more
relevant tasks or goals for the examples and a more measured
approach to the docs and why, in this project, Org Mode trumps reST,
even though it's Python through and through.
* lang/python/gpgme.i: copied signature from gpgme.h and defaulted the
value to SEEK_SET.
* lang/python/tests/t-data.py: Added a test for no second argument
--
Having to import the os package when wanting to read a Data object is a
slight annoyance. With SWIG, we can define default parameters. This
change defaults the whence argument to SEEK_SET which is how StringIO
and BytesIO behave.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/tests/Makefile.am: Distinguish target and path.
* tests/gpg/Makefile.am: Ditto.
* tests/gpgsm/Makefile.am: Ditto.
--
GNU Make is powerful enough to match path to target (and vice versa),
but BSD make is not.
GnuPG-bug-id: 3056
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* NEWS: Update.
* lang/python/src/core.py (Context.__read__): New helper function.
(Context.encrypt): Attach partial results to exceptions.
(Context.decrypt): Likewise.
(Context.sign): Likewise.
(Context.verify): Likewise.
* lang/python/src/errors.py (GpgError): Move the core of GPGMEError to
this class, add a nicer interface for it. This makes the errors
thrown by this library more uniform, and allows us to track the
underlying error in synthesized high-level errors.
(GPGMEError): Simplify.
(...): Make sure to call the parent classes' constructor in all other
classes.
--
Attach partial results to errors. Some operations return results even
though they signal an error. Of course this information must be taken
with a grain of salt. But often, this information is useful for
diagnostic uses or to give the user feedback. Since the normal
control flow is disrupted by the exception, the callee can no longer
return results, hence we attach them to the exception objects.
GnuPG-bug-id: 3271
Signed-off-by: Justus Winter <justus@g10code.com>
* NEWS: Update.
* lang/cpp/src/decryptionresult.cpp (DecryptionResult::isDeVs): New
function.
* lang/cpp/src/decryptionresult.h (DecryptionResult::isDeVs): New
prototype.
* lang/cpp/src/verificationresult.cpp (Signature::isDeVs): New
function.
* lang/cpp/src/verificationresult.h (Signature::isDeVs): New
prototype.
* lang/python/src/results.py (DecryptResult): Turn field 'is_de_vs'
into a boolean.
(Signature): Likewise.
* src/decrypt.c (_gpgme_decrypt_status_handler): Handle the new
compliance status line.
* src/verify.c (_gpgme_verify_status_handler): Likewise.
* src/gpgme.h.in (gpgme_status_code_t): Add new status codes for the
new status lines.
* src/keylist.c (parse_pub_field18): Move function to 'util.h'.
(keylist_colon_handler): Adapt callsites.
* src/status-table.c (status_table): Add new status lines.
* src/util.h (PARSE_COMPLIANCE_FLAGS): New macro. This used to be
'parse_pub_field18', but turned into a macro to make it polymorphic.
--
When decrypting data and verifying signatures, report whether the
operations are in compliance with the criteria for data classified as
VS-NfD. This information can the be presented to the user.
GnuPG-bug-id: 3059
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/setup.py.in: Prepend the Python build dir to the list of
include directories so that it takes precedence over any other include
directory.
--
Fixes the build in case an older 'gpgme.h' is installed and is picked
up by the compiler when compiling the Python module.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/Makefile.am (pubring-stamp): Do not depend on the
configuration files, this can trigger superfluous rebuilds.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/Makefile.am: Kill all previously running daemons
before creating the private key store.
* lang/qt/tests/Makefile.am: Likewise.
* tests/gpg/Makefile.am: Likewise.
* tests/gpgsm/Makefile.am: Likewise.
--
Now that the daemons sockets are no longer created in the GNUPGHOME,
we cannot rely on cleaning the build directory to make sure they are
shut down. Therefore, we explicitly kill any running daemons when
creating the test environment.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/Makefile.am: Create test environment as part of
'make all'.
* tests/gpg/Makefile.am: Make sure the private keystore is created
first.
* tests/gpgsm/Makefile.am: Create test environment as part of
'make all'. Make sure the private keystore is created
first.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/support.py (have_tofu_support): New function.
* lang/python/tests/t-quick-key-manipulation.py: Skip TOFU test if not
supported by GnuPG.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/run-tests.py: Add --python-libdir optional
parameter.
--
This will make the python tests usable for downstream that build python
module outside of autotools build system.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/setup.py.in: Read gpg-error.h using the pre-processor.
--
The libgpg-error may be installed in multilib configuration in which
there is a wrapper header at /usr/include that includes the actual
header at /usr/include/*. This causes invalid errors.i generation.
Let the pre-processor extract the header content instead reading it
explicitly.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* configure.ac: Remove PYTHON_VERSIONS subst.
* lang/python/Makefile.am: Use basename of python as builddir prefix.
* lang/python/tests/run-tests.py: Likewise.
--
Two variables needs be at sync PYTHONS and PYTHON_VERSIONS, these may go
out of sync in some cases, for example in Gentoo where default python is
3.4 we get:
PYTHON='/usr/bin/python2'
PYTHONS='/usr/bin/python /usr/bin/python2'
PYTHON_VERSIONS='2.7 3.4'
We can use the basename of the python interpreter to achieve similar
effect without having to sync indexes between these two variables.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/setup.py.in: Do not parse arguments.
--
The distutils settings can come from either command-line or
configuration file. Parsing parameters is not working in all cases.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
configure.ac: Generate version.py.in in lang/python.
* lang/python/MANIFEST.in: Include version.py explicitly.
* lang/python/gpg: Rename to 'src'.
* lang/python/Makefile.am: Do not copy source files, do not use absolute
directories, support lib64 in uninstall, clean also dist directory, use
symlink for gpg src.
* lang/python/setup.py.in: Use builddir, copy sources into builddir,
copy version.py into module.
--
Simplify build to symlink the gpg sources into builddir instead of
copying. This requires handling of version.py as generated file.
In addition apply some cleanups: Drop the absolution pathes, clean the
dist directory as well, support lib64 for sitelib at uninstall.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/gpgme-h-clean.py: Delete file.
* lang/python/MANIFEST.in: Adapt accordingly.
* lang/python/Makefile.am (EXTRA_DIST): Likewise.
(COPY_FILES_GPG): Bring variable back.
(copystamp): Copy files.
(clean-local): Delete copied files.
(install-exec-local): Do not create and install list of installed
files.
(uninstall-local): Instead, create some explicit rules to uninstall
the extension.
* lang/python/setup.py.in: Parse arguments. Locate files either in
the source directory, or in the build base directory. Inline the code
from 'gpgme-h-clean.py'. Copy 'helpers.c', add source directory as
include directory.
Fixes-commit: 801d7d8c5d
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/setup.py.in: Generate files within BuildExtFirstHack
adjust build flags at this point instead of global.
* lang/python/Makefile.am: Remove logic of separate source directory per
python version in favor of build directory.
* lang/python/tests/run-tests.py: Adjust build directory location.
--
Generate files into build directory, leaving the source directory clean.
Use the same source directory for multiple python version build. Result
of 'prepare' target is a standard distutil layout that can be used
easily by downstream to build all python targets in-place.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/Makefile.am: Fix 'prepare' target.
* lang/python/setup.py.in: Use 'abs_top_builddir' instead of guessing
the path.
--
'prepare' will prepare target at PREPAREDIR. The automake integration
will also make use of prepare target. Downstream distributors may
also make use of prepare target.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
* lang/python/tests/support.py (assert_gpg_version): Fix error
message. Skip all tests when we use GnuPG older than 2.1.12.
GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): New keyword argument
'source'. If given, list keys from 'source'.
* lang/python/gpgme.i: Wrap the argument to
'gpgme_op_keylist_from_data_start'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/support.py (EphemeralContext): Do not throw an
error if no agent has been started in the context.
* lang/python/tests/t-keylist-from-data.py: New file.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/Makefile.am (gpg-agent.conf): Do not hard-code the
option. This breaks gpg-agent from GnuPG 2.0.
* tests/start-stop-agent: Rather, check if the option is supported and
add it to the configuration if it is.
GnuPG-bug-id: 3008
Fixes-commit: bbf19124bb
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/support.py (assert_gpg_version): New function.
* lang/python/tests/t-callbacks.py: Use the new function to skip the
test if GnuPG is too old.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-quick-key-creation.py: Likewise.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-key-signing.py: Likewise.
GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/run-tests.py: Make the error message shown when we
cannot locate the python module in the build tree more helpful.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/support.py (TemporaryDirectory): Always use our
own version even if 'tempfile.TemporaryDirectory' is provided, because
we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
tripping over gpg-agent deleting its own sockets.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/initial.py: Print path of the Python module used
during tests. Useful to detect if by any mistake the wrong module is
picked up.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/t-quick-key-manipulation.py: Modify the
configuration file in the ephemeral home directory, not the one used
by all the tests.
Fixes-commit: 15fbac9e72
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/tests/support.py (EphemeralContext): New function.
* lang/python/tests/t-quick-key-creation.py: Use the new function to
manage ephemeral contexts.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-subkey-creation.py: Likewise.
--
Previously, there was a problem with cleaning up ephemeral home
directories. shutil.rmtree deleted the agents main socket, gpg-agent
detected that, and deleted the other sockets as well, racing
shutil.rmtree which did not cope will with that.
Fix this by asking the agent nicely to shut down.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/gpg/core.py (Context.assuan_transact): Fix testing
whether the command is a string on Python2.
* lang/python/tests/t-protocol-assuan.py: Improve the test to detect
this problem.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/Makefile.am (copystamp): Also copy the setup script, and
link the header files.
(all-local): Use local setup script.
(sdist): Fix Python source distribution creation.
(CLEANFILES): Remove now obsolete files.
(install-exec-local): Use local setup script.
* lang/python/setup.py.in: Adjust relative paths to in-tree files.
Fixes-commit: fe65a26ab5
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/gpgme.i: Added a genericrepr macro and use it for
gpgme_key, gpgme_subkey, and gpgme_key_sig.
--
To look nicer in Python's REPL.
We define a generic __repr__ as a SWIG macro and use that to extend some
defined SWIG objects.
The alternative would have been to write a custom __repr__ function for
each class but that would need to be changed everytime the object's
structure changes. The bindings should be easy to maintain, I guess.
This comes at the expense that the reprs are now relatively long and
contain, for example, both keyid and fingerprint.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/setup.py.in: Call SWIG without the builtin flag.
--
The SWIG documentation
<http://www.swig.org/Doc2.0/Python.html#Python_nn28> leaves the
impression that -builtin is solely for increasing performance:
New in SWIG version 2.0.4: The use of Python proxy classes has
performance implications that may be unacceptable for a high-
performance library. The new -builtin option instructs SWIG to
forego the use of proxy classes, and instead create wrapped types as
new built-in Python types. When this option is used, the following
section ("Proxy classes") does not apply. Details on the use of the
-builtin option are in the Built-in Types section.
While not wasting CPU cycles is good, it also prevents Python code being
written in the wrapper itself. That, however, may be useful to make it
easier to extend the wrapper.
Partially reverts: 856bcfe293
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Provide a "self"
variable for SWIG_NewPointerObj and call SWIG_NewPointerObj rather than
SWIG_Python_NewPointerObj.
--
SWIG_Python_NewPointerObj seems to be an implementation detail, because
SWIG's documentation does not mention that function at all. In fact,
SWIG_NewPointerObj is a call to SWIG_Python_NewPointerObj with the first
parameter being either NULL or the "self" variable, depending on whether
SWIG is called with the -builtin flag. So far, the first parameter was
hard-coded to NULL. This change also hard-codes it to NULL but makes
it more explicit. The benefit is that the documented function is being
used and that compilation works regardless of the -builtin flag.
Partially reverts: 856bcfe293
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/setup.py.in: Only call with -py3 when we run under python3
or higher.
--
If we ever remove the -builtin flag and leave the the -py3 flag, SWIG
will generate Python code which will be incompatible with Python 2,
because the py3 flag generates python3 code which is incompatible with
python2.
So we conditionally generate SWIG bindings with -py3.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/Makefile.am (copystamp): Create one copy per Python
version.
(all-local): Adapt.
(clean-local): Likewise.
(install-exec-local): Likewise.
* lang/python/tests/run-tests.py: Likewise.
--
Currently, we use one copy of the Python module's source to build for
all Python versions. This is problematic, because SWIG writes a
wrapper file into the source tree. Currently, this file works with
both Python 2 and 3, but this is purely by chance.
Improve the situation by creating one copy per Python version so that
SWIG can write version-specific code into each copy.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/gpgme.i: Added gpgme_op_keylist_start with defaults
* lang/python/tests/t-keylist.py: Added tests for default parameters
--
To increase the ease of use, op_keylist_start
parameters default to sensible values.
The empty string matches all keys.
We assume that the user wants to retrieve public keys most of the time,
so we default to public keys rather than secret keys.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/tests/run-tests.py: Add and honor a switch '--quiet'.
This way we can use this script to run Python tests one by one without
the noise, and the script will setup the necessary environment for us.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/helpers.c (_gpg_obj2gpgme_data_t): Extended error
message.
* lang/python/tests/t-encrypt.py: Test for "encode" in error message.
--
The motivation is to help the user when encrypting fails. I claim that
it is not obvious to not being able to encrypt a string directly. To
nudge the user into encoding it to bytes, the error message is a bit
extended.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/gpgme.i (wrapresult): New Macro.
--
This reduces the amount of copy and pasted code at the expense of a
slightly more complicated logic with a macro.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/tests/support.py (print_data): Add check for buffer.
--
When running with something like make -C lang/python check verbose=2 the
test would fail under python2, because the file objects do not have a
buffer property.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/gpg/core.py (Context.__repr__): New function.
--
This makes Context objects look nicer in a REPL.
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
* lang/python/gpg/results.py (Result.__str__): Renamed to '__repr__'
...
* lang/python/gpg/results.py (Result.__repr__): ... and added fields.
--
So that it looks a bit nicer in the Python REPL.
It looked like this before:
In [2]: gpg.core.get_engine_info()[0]
Out[2]:
<gpg.results.EngineInfo at 0x7fb23509a240>
Now the output is
In [2]: gpg.core.get_engine_info()[0]
Out[2]:
EngineInfo(file_name='/usr/bin/gpg2', home_dir=None,
protocol=0, req_version='1.4.0', version='2.1.11')
This also applies to other results, e.g. the ImportResult.
Note that the format now changed from "<Class >" to "Class()". The
Python documentation on repr states: "For many object types, including
most builtins, eval(repr(obj)) == obj."
Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>