[Spice-devel] [PATCH 3/4] Add check for pyparsing

Christophe Fergeau cfergeau at redhat.com
Tue Jan 24 09:03:25 PST 2012


Check both in configure.ac (after checking if we need to rebuild
the marshalling files) and in the python script using pyparsing
(for people modifying .proto files in tarballs)
---
 configure.ac                   |   11 +++++++++++
 python_modules/spice_parser.py |   10 +++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1288091..7ed01c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,17 @@ AC_SUBST(PROTOCOL_CFLAGS)
 AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
+srcdir="$(dirname $0)"
+if test ! -e "$srcdir/gtk/generated_marshallers.c"; then
+  AC_MSG_CHECKING([for pyparsing python module])
+  echo "import pyparsing" | python - >/dev/null 2>&1
+  if test $? -ne 0 ; then
+    AC_MSG_RESULT([not found])
+    AC_MSG_ERROR([pyparsing python module is required to compile this package])
+  fi
+  AC_MSG_RESULT([found])
+fi
+
 SPICE_GLIB_REQUIRES=""
 SPICE_GTK_REQUIRES=""
 
diff --git a/python_modules/spice_parser.py b/python_modules/spice_parser.py
index a71b2c2..f634800 100644
--- a/python_modules/spice_parser.py
+++ b/python_modules/spice_parser.py
@@ -1,6 +1,10 @@
-from pyparsing import Literal, CaselessLiteral, Word, OneOrMore, ZeroOrMore, \
-        Forward, delimitedList, Group, Optional, Combine, alphas, nums, restOfLine, cStyleComment, \
-        alphanums, ParseException, ParseResults, Keyword, StringEnd, replaceWith
+try:
+    from pyparsing import Literal, CaselessLiteral, Word, OneOrMore, ZeroOrMore, \
+            Forward, delimitedList, Group, Optional, Combine, alphas, nums, restOfLine, cStyleComment, \
+            alphanums, ParseException, ParseResults, Keyword, StringEnd, replaceWith
+except ImportError:
+    print "Module pyparsing not found."
+    exit(1)
 
 import ptypes
 import sys
-- 
1.7.7.6



More information about the Spice-devel mailing list