Get the patience diff module compiling and loading

This commit is contained in:
Kovid Goyal 2014-01-16 20:57:31 +05:30
parent b98677d9b1
commit 0409241765
4 changed files with 26 additions and 2 deletions

View File

@ -89,6 +89,10 @@ extensions = [
['calibre/utils/speedup.c'], ['calibre/utils/speedup.c'],
), ),
Extension('_patiencediff_c',
['calibre/utils/diff/_patiencediff_c.c'],
),
Extension('icu', Extension('icu',
['calibre/utils/icu.c'], ['calibre/utils/icu.c'],
libraries=icu_libs, libraries=icu_libs,

View File

@ -141,6 +141,7 @@ class Plugins(collections.Mapping):
'qt_hack', 'qt_hack',
'_regex', '_regex',
'hunspell', 'hunspell',
'_patiencediff_c',
] ]
if iswindows: if iswindows:
plugins.extend(['winutil', 'wpd', 'winfonts']) plugins.extend(['winutil', 'wpd', 'winfonts'])

View File

@ -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 <kovid at kovidgoyal.net>'
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

View File

@ -23,11 +23,11 @@
*/ */
#include <Python.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <Python.h>
#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__) #if defined(__GNUC__)