* Daniele Tricoli <er...@mornie.org>, 2011-05-25, 02:33:
I'm working on #555363 to get rid of embedded copy of python-ply from python-pyke. python-pyke ships some tables with _tabversion="3.2" so it can right use python-ply 3.3-1 and also (when it will be packaged) ply 3.4 which use the same table version without rebuilding cached tables. If you can provide a virtual package, e.g. python-ply-X.Y, where X.Y is the required table version, other packages could simply depend on the virtual package, without having to anticipate when the compatibility will break.

Here's a patch implementing this. I use two virtual packages, because version number embedded in lextab and parsetab can differ (and some users might don't care about lextab at all, since it's not stored on disk by default).

The only missing bit, which would be nice to have, is a script to automatically generate correct dependencies on these virtual packages for packages that ship pre-generatare parser/lexer tables.

--
Jakub Wilk
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -17,6 +17,7 @@
 Package: python-ply
 Architecture: all
 Depends: ${python:Depends}, ${misc:Depends}
+Provides: ${python-ply:Provides}
 Suggests: python-ply-doc, python-pkg-resources
 Description: Lex and Yacc implementation for Python
  PLY   is   yet  another   implementation   of   lex   and  yacc   for
diff --git a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -11,3 +11,6 @@
 
 DEB_DESTDIR := debian/python-ply
 DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed
+
+binary-post-install/python-ply::
+	echo "python-ply:Provides=$$(python debian/virtual-packages.py)" >> debian/python-ply.substvars
diff --git a/debian/virtual-packages.py b/debian/virtual-packages.py
new file mode 100644
--- /dev/null
+++ b/debian/virtual-packages.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+import os
+import shutil
+import tempfile
+
+import ply.lex
+import ply.yacc
+
+tokens = ['token']
+
+t_token = 'x'
+
+def t_error(t):
+    pass
+
+def p_dummy(p):
+    'dummy : token'
+    pass
+
+def p_error(p):
+    pass
+
+def read_tabversion(filename):
+    file = open(filename)
+    data = {}
+    try:
+        exec file in data
+    finally:
+        file.close()
+    return data['_tabversion']
+
+tmpdir = tempfile.mkdtemp()
+try:
+    ply.lex.lex(outputdir=tmpdir, optimize=True)
+    ply.yacc.yacc(outputdir=tmpdir, optimize=True, debug=False)
+    lex_tabversion = read_tabversion(os.path.join(tmpdir, 'lextab.py'))
+    yacc_tabversion = read_tabversion(os.path.join(tmpdir, 'parsetab.py'))
+    print 'python-ply-lex-%s, python-ply-yacc-%s' % (lex_tabversion, yacc_tabversion)
+finally:
+    shutil.rmtree(tmpdir)
+
+# vim:ts=4 sw=4 et

Reply via email to