From 0409241765f8f824215261711a88051a5bef7fc4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Jan 2014 20:57:31 +0530 Subject: [PATCH] Get the patience diff module compiling and loading --- setup/extensions.py | 4 ++++ src/calibre/constants.py | 1 + src/calibre/utils/diff/__init__.py | 19 +++++++++++++++++++ src/calibre/utils/diff/_patiencediff_c.c | 4 ++-- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/calibre/utils/diff/__init__.py diff --git a/setup/extensions.py b/setup/extensions.py index ddff61af6a..74ff5a88db 100644 --- a/setup/extensions.py +++ b/setup/extensions.py @@ -89,6 +89,10 @@ extensions = [ ['calibre/utils/speedup.c'], ), + Extension('_patiencediff_c', + ['calibre/utils/diff/_patiencediff_c.c'], + ), + Extension('icu', ['calibre/utils/icu.c'], libraries=icu_libs, diff --git a/src/calibre/constants.py b/src/calibre/constants.py index a521ac1670..eab38f272c 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -141,6 +141,7 @@ class Plugins(collections.Mapping): 'qt_hack', '_regex', 'hunspell', + '_patiencediff_c', ] if iswindows: plugins.extend(['winutil', 'wpd', 'winfonts']) diff --git a/src/calibre/utils/diff/__init__.py b/src/calibre/utils/diff/__init__.py new file mode 100644 index 0000000000..ad765c8871 --- /dev/null +++ b/src/calibre/utils/diff/__init__.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +from __future__ import (unicode_literals, division, absolute_import, + print_function) + +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + +from calibre.constants import plugins + +def load_patience_module(): + p, err = plugins['_patiencediff_c'] + if err is not None: + raise ImportError('Failed to import the PatienceDiff C module with error: %s' % err) + return p + +def get_sequence_matcher(): + return load_patience_module().PatienceSequenceMatcher_c + diff --git a/src/calibre/utils/diff/_patiencediff_c.c b/src/calibre/utils/diff/_patiencediff_c.c index 4de410d289..797b3f90e1 100644 --- a/src/calibre/utils/diff/_patiencediff_c.c +++ b/src/calibre/utils/diff/_patiencediff_c.c @@ -23,11 +23,11 @@ */ +#include #include #include -#include -#include "python-compat.h" +/* #include "python-compat.h" Commented out by Kovid as nothing defined in it is needed for this module */ #if defined(__GNUC__)