[packages/python-pyopenfst] - new, alternative Python binding to openfst - added update patch (adapt to recent openfst version)

qboosh qboosh at pld-linux.org
Sun Mar 18 20:53:21 CET 2018


commit be17d6f7dcd7c278c52a4412f285ad8216e1528f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun Mar 18 20:56:00 2018 +0100

    - new, alternative Python binding to openfst
    - added update patch (adapt to recent openfst version)
    - added tests patch (avoid SEGV in one test)
    - added python3 patch (fix one python2 vs python3 issue)

 pyopenfst-python3.patch |  19 +++++++
 pyopenfst-tests.patch   |  10 ++++
 pyopenfst-update.patch  |  31 +++++++++++
 python-pyopenfst.spec   | 145 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 205 insertions(+)
---
diff --git a/python-pyopenfst.spec b/python-pyopenfst.spec
new file mode 100644
index 0000000..2febbdb
--- /dev/null
+++ b/python-pyopenfst.spec
@@ -0,0 +1,145 @@
+#
+# Conditional build:
+%bcond_without	tests	# unit tests
+%bcond_without	python2 # CPython 2.x module
+%bcond_without	python3 # CPython 3.x module
+
+Summary:	PyOpenFST - Python 2 bindings to OpenFTS library
+Summary(pl.UTF-8):	PyOpenFST - wiązania Pythona 2 do biblioteki OpenFST
+Name:		python-pyopenfst
+Version:	0.4
+%define	snap	20141029
+%define	gitref	eb0c0f9af57bb597f9511e1cc69cbbefe50ff507
+Release:	0.%{snap}.1
+License:	Apache v2.0
+Group:		Libraries/Python
+Source0:	https://github.com/tmbdev/pyopenfst/archive/%{gitref}/pyopenfst-%{snap}.tar.gz
+# Source0-md5:	39e3516a6d80cd2604d9dc76de48a9a5
+Patch0:		pyopenfst-update.patch
+Patch1:		pyopenfst-tests.patch
+Patch2:		pyopenfst-python3.patch
+URL:		https://github.com/tmbdev/pyopenfst
+BuildRequires:	libstdc++-devel >= 6:4.7
+BuildRequires:	openfst-devel
+BuildRequires:	rpm-pythonprov
+BuildRequires:	rpmbuild(macros) >= 1.714
+BuildRequires:	swig-python >= 2
+%if %{with python2}
+BuildRequires:	python-devel >= 2.0
+%endif
+%if %{with python3}
+BuildRequires:	python3-devel >= 1:3.2
+%endif
+Requires:	python-libs >= 2.0
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+The OpenFST library implements algorithms on weighted finite state
+transducers. The PyOpenFST project contains bindings for the library.
+
+%description -l pl.UTF-8
+Biblioteka OpenFST implementuje algorytmy na automatach skończonych z
+wyjściem i wagami. Projekt PyOpenFST zawiera wiązania Pythona do
+biblioteki.
+
+%package -n python3-pyopenfst
+Summary:	PyOpenFST - Python 3 bindings to OpenFTS library
+Summary(pl.UTF-8):	PyOpenFST - wiązania Pythona 3 do biblioteki OpenFST
+Group:		Libraries/Python
+Requires:	python3-libs >= 1:3.2
+
+%description -n python3-pyopenfst
+The OpenFST library implements algorithms on weighted finite state
+transducers. The PyOpenFST project contains bindings for the library.
+
+%description -n python3-pyopenfst -l pl.UTF-8
+Biblioteka OpenFST implementuje algorytmy na automatach skończonych z
+wyjściem i wagami. Projekt PyOpenFST zawiera wiązania Pythona do
+biblioteki.
+
+%prep
+%setup -q -n pyopenfst-%{gitref}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+
+%build
+# setup.py uses CFLAGS for C++; openfst requires C++11
+CFLAGS="%{rpmcxxflags} -std=c++11"
+
+%if %{with python2}
+%py_build
+
+%if %{with tests}
+PYTHONPATH=$(echo build-2/lib.*) \
+%{__python} -munittest test-openfst test-openfst0 test-openfst1
+%endif
+%endif
+
+%if %{with python3}
+%py3_build
+
+%if %{with tests}
+PYTHONPATH=$(echo build-3/lib.*) \
+%{__python3} -munittest test-*.py
+%endif
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%py_install
+%py_postclean
+%endif
+
+%if %{with python3}
+%py3_install
+%endif
+
+%if %{with python2}
+install -d $RPM_BUILD_ROOT%{_examplesdir}/python-pyopenfst-%{version}
+cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-pyopenfst-%{version}
+%endif
+%if %{with python3}
+install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-pyopenfst-%{version}
+cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-pyopenfst-%{version}
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc README.md
+%{py_sitedir}/openfst.py[co]
+%attr(755,root,root) %{py_sitedir}/_openfst.so
+%{py_sitedir}/openfst-%{version}-py*.egg-info
+%dir %{_examplesdir}/%{name}-%{version}
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/dict2linefst
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/lines2linefst
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/pyfst-*
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/test-ngraph
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/text2ngraphfst
+%attr(755,root,root) %{_examplesdir}/%{name}-%{version}/wdict2wordfst
+%{_examplesdir}/%{name}-%{version}/dict-*
+%endif
+
+%if %{with python3}
+%files -n python3-pyopenfst
+%defattr(644,root,root,755)
+%doc README.md
+%{py3_sitedir}/openfst.py
+%attr(755,root,root) %{py3_sitedir}/_openfst.cpython-*.so
+%{py3_sitedir}/__pycache__/openfst.cpython-*.py[co]
+%{py3_sitedir}/openfst-%{version}-py*.egg-info
+%dir %{_examplesdir}/python3-pyopenfst-%{version}
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/dict2linefst
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/lines2linefst
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/pyfst-*
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/test-ngraph
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/text2ngraphfst
+%attr(755,root,root) %{_examplesdir}/python3-pyopenfst-%{version}/wdict2wordfst
+%{_examplesdir}/python3-pyopenfst-%{version}/dict-*
+%endif
diff --git a/pyopenfst-python3.patch b/pyopenfst-python3.patch
new file mode 100644
index 0000000..51a6ea6
--- /dev/null
+++ b/pyopenfst-python3.patch
@@ -0,0 +1,19 @@
+--- pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_iterators.i.orig	2014-10-28 21:34:59.000000000 +0100
++++ pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_iterators.i	2018-03-18 08:20:45.129703020 +0100
+@@ -12,7 +12,7 @@
+         "Method to be overriden which returns the iterator's value"
+         return self.itor
+ 
+-    def next(self):
++    def __next__(self):
+         if self.first:
+             self.first = False
+         else:
+@@ -20,6 +20,7 @@
+         if self.itor.Done():
+             raise StopIteration
+         return self.get()
++    next = __next__
+ 
+ class SymbolTable_iter(IteratorProxy):
+     def get(self):
diff --git a/pyopenfst-tests.patch b/pyopenfst-tests.patch
new file mode 100644
index 0000000..0517ebb
--- /dev/null
+++ b/pyopenfst-tests.patch
@@ -0,0 +1,10 @@
+--- pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/test-openfst1.py.orig	2018-03-17 20:33:29.360187559 +0100
++++ pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/test-openfst1.py	2018-03-17 20:33:35.736854151 +0100
+@@ -11,6 +11,7 @@
+         nst = fst.AddState()
+         self.assertEquals(nst, 1)
+         fst.AddArc(st, 42, 69, 55, nst);
++        fst.SetStart(0) # required for fst.Properties to to SEGV
+         self.assertEquals(fst.NumArcs(st), 1)
+         self.assertEquals(fst.Properties(openfst.kFstProperties, True)
+                           & openfst.kNotAcceptor,
diff --git a/pyopenfst-update.patch b/pyopenfst-update.patch
new file mode 100644
index 0000000..e156589
--- /dev/null
+++ b/pyopenfst-update.patch
@@ -0,0 +1,31 @@
+--- pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_symtab.i.orig	2014-10-28 21:34:59.000000000 +0100
++++ pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_symtab.i	2018-03-12 19:10:25.371843803 +0100
+@@ -19,7 +19,7 @@
+     SymbolTable *Copy() const;
+     %feature("docstring", "Read entries from a text file.");
+     static SymbolTable* ReadText(std::string const & filename,
+-                                 bool allow_negative = false);
++                                 const SymbolTableTextOptions &opts = SymbolTableTextOptions());
+     %feature("docstring", "Write entries to a text file.");
+     bool WriteText(std::string const & filename) const;
+     %feature("docstring", "Read entries from a binary file.");
+--- pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_properties.i.orig	2014-10-28 21:34:59.000000000 +0100
++++ pyopenfst-eb0c0f9af57bb597f9511e1cc69cbbefe50ff507/openfst_properties.i	2018-03-12 19:02:13.431849424 +0100
+@@ -64,7 +64,7 @@
+ uint64 ComposeProperties(uint64 inprops1, uint64 inprops2);
+ uint64 ConcatProperties(uint64 inprops1, uint64 inprops2,
+                         bool delayed = false);
+-uint64 DeterminizeProperties(uint64 inprops, bool has_subsequential_label);
++uint64 DeterminizeProperties(uint64 inprops, bool has_subsequential_label, bool distinct_psubsequential_labels);
+ //uint64 DifferenceProperties(uint64 inprops1, uint64 inprops2);
+ uint64 FactorWeightProperties(uint64 inprops);
+ //uint64 IntersectProperties(uint64 inprops1, uint64 inprops2);
+@@ -75,7 +75,7 @@
+ //                          ssize_t root,
+ //                          bool epsilon_on_replace,
+ //                          bool no_empty_fst);
+-uint64 ReverseProperties(uint64 inprops);
++uint64 ReverseProperties(uint64 inprops, bool has_superinitial);
+ uint64 ReweightProperties(uint64 inprops);
+ uint64 RmEpsilonProperties(uint64 inprops, bool delayed = false);
+ uint64 SynchronizeProperties(uint64 inprops);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-pyopenfst.git/commitdiff/be17d6f7dcd7c278c52a4412f285ad8216e1528f



More information about the pld-cvs-commit mailing list