[Python-modules-commits] r17415 - in packages/ply/trunk/debian (6 files)
arnau at users.alioth.debian.org
arnau at users.alioth.debian.org
Sun Jun 12 13:46:29 UTC 2011
Date: Sunday, June 12, 2011 @ 13:46:27
Author: arnau
Revision: 17415
Provide virtual packages for lex and yacc tabversions. Thanks to Jakub Wilk. Closes: #627862.
Added:
packages/ply/trunk/debian/dh_python-ply
packages/ply/trunk/debian/virtual-packages.py
Modified:
packages/ply/trunk/debian/changelog
packages/ply/trunk/debian/control
packages/ply/trunk/debian/python-ply.install
packages/ply/trunk/debian/rules
Modified: packages/ply/trunk/debian/changelog
===================================================================
--- packages/ply/trunk/debian/changelog 2011-06-12 13:12:47 UTC (rev 17414)
+++ packages/ply/trunk/debian/changelog 2011-06-12 13:46:27 UTC (rev 17415)
@@ -15,6 +15,8 @@
- Build-Depends on python3-all and add X-Python3-Version field.
* debian/copyright:
+ Update copyright years.
+ * Provide virtual packages for lex and yacc tabversions. Thanks to Jakub
+ Wilk. Closes: #627862.
[ Daniele Tricoli ]
* debian/control:
Modified: packages/ply/trunk/debian/control
===================================================================
--- packages/ply/trunk/debian/control 2011-06-12 13:12:47 UTC (rev 17414)
+++ packages/ply/trunk/debian/control 2011-06-12 13:46:27 UTC (rev 17415)
@@ -7,7 +7,8 @@
Build-Depends: debhelper (>= 5.0.37.2),
cdbs (>= 0.4.90-1~),
python-all (>= 2.6.6-9~),
- python3-all (>= 3.1.2-6~)
+ python3-all (>= 3.1.2-6~),
+ perl
Build-Depends-Indep: python-setuptools (>= 0.6a9)
X-Python-Version: >= 2.3
X-Python3-Version: >= 3.0
@@ -19,7 +20,7 @@
Package: python-ply
Architecture: all
Depends: ${python:Depends}, ${misc:Depends}
-Provides: ${python:Provides}
+Provides: ${python:Provides}, ${python-ply:Provides}
Breaks: ${python:Breaks}
Suggests: python-ply-doc, python-pkg-resources
Description: Lex and Yacc implementation for Python2
@@ -39,9 +40,9 @@
Package: python3-ply
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}
-Provides: ${python3:Provides}
+Provides: ${python3:Provides}, ${python3-ply:Provides}
Breaks: ${python3:Breaks}
-Suggests: python-ply-doc, python-pkg-resources
+Suggests: python-ply-doc, python3-pkg-resources
Description: Lex and Yacc implementation for Python3
PLY is yet another implementation of lex and yacc for
Python. Although several other parsing tools are available for
Added: packages/ply/trunk/debian/dh_python-ply
===================================================================
--- packages/ply/trunk/debian/dh_python-ply (rev 0)
+++ packages/ply/trunk/debian/dh_python-ply 2011-06-12 13:46:27 UTC (rev 17415)
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+dh_python-ply - generate versioned dependencies on python-ply
+
+=cut
+
+use strict;
+use warnings;
+
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_python-ply> [B<--dependency-field> I<dependencyfield>] [S<I<debhelper options>>] I<file>...
+
+=head1 DESCRIPTION
+
+B<dh_python-ply> is a debhelper program that is responsible for generating the
+B<python-ply:Depends> substitutions and adding them to substvars files.
+
+The program will look only at Python modules that are explicitly provided as
+its arguments, and will use this information to generate a strict versioned
+dependency on B<python-ply>.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--dependency-field> I<dependencyfield>
+
+Use B<python-ply:>I<dependencyfield> substitution variable instead of
+B<python-ply:Depends>.
+
+=back
+
+=cut
+
+my $dependency_field = "Depends";
+
+init(options => { "dependency-field:s" => \$dependency_field });
+
+if (not @ARGV)
+{
+ error("at least one argument is required")
+}
+
+foreach my $filename (@ARGV)
+{
+ open FILE, $filename or error("cannot read $filename: $!");
+ read FILE, $_, 1024;
+ my $is_lextab = /^_lextokens\b/m;
+ my $is_parsetab = /^_lr_method\b/m;
+ $is_lextab or $is_parsetab or error("$filename doesn't look like a PLY table");
+ (my $tabversion) = /^_tabversion\s*=\s*'([0-9.]+)'/m or error("$filename was generated by a very old PLY");
+ my $dependency = sprintf "python-ply-%s-%s", $is_lextab ? "lex" : "yacc", $tabversion;
+ # Prefer real package names of "old" versions of PLY for easier upgrades from squeeze:
+ if ($dependency eq "python-ply-yacc-3.2")
+ {
+ # PLY 3.2, 3.3 and 3.4 embeds the same version number (3.2) in parser tables.
+ $dependency = "python-ply (>= 3.2), python-ply (<< 3.5) | $dependency";
+ }
+ elsif ($dependency eq "python-ply-lex-3.3")
+ {
+ # PLY 3.2, 3.3 and 3.4 embeds their own version number in lexer tables.
+ $dependency = "python-ply (>= 3.3), python-ply (<< 3.4) | $dependency";
+ }
+ foreach my $package (@{$dh{DOPACKAGES}})
+ {
+ addsubstvar($package, "python-ply:$dependency_field", $dependency);
+ }
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is not a part of debhelper, but it is meant to be used together with it.
+
+=head1 AUTHOR
+
+Jakub Wilk <jwilk at debian.org>
+
+=cut
+
+# vim:ts=4 sw=4 et
Modified: packages/ply/trunk/debian/python-ply.install
===================================================================
--- packages/ply/trunk/debian/python-ply.install 2011-06-12 13:12:47 UTC (rev 17414)
+++ packages/ply/trunk/debian/python-ply.install 2011-06-12 13:46:27 UTC (rev 17415)
@@ -1 +1,2 @@
debian/tmp/usr/lib/python2* usr/lib/
+debian/dh_python-ply usr/bin/
Modified: packages/ply/trunk/debian/rules
===================================================================
--- packages/ply/trunk/debian/rules 2011-06-12 13:12:47 UTC (rev 17414)
+++ packages/ply/trunk/debian/rules 2011-06-12 13:46:27 UTC (rev 17415)
@@ -9,3 +9,16 @@
DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed \
--install-layout=deb
+
+binary-install/python-ply::
+ pod2man debian/dh_python-ply > dh_python-ply.1
+ dh_installman -p python-ply dh_python-ply.1
+ rm dh_python-ply.1
+
+binary-post-install/python-ply::
+ echo "python-ply:Provides=$$(python debian/virtual-packages.py $(cdbs_curpkg))" >> \
+ debian/python-ply.substvars
+
+binary-post-install/python3-ply::
+ echo "python3-ply:Provides=$$(python debian/virtual-packages.py $(cdbs_curpkg))" >> \
+ debian/python3-ply.substvars
Added: packages/ply/trunk/debian/virtual-packages.py
===================================================================
--- packages/ply/trunk/debian/virtual-packages.py (rev 0)
+++ packages/ply/trunk/debian/virtual-packages.py 2011-06-12 13:46:27 UTC (rev 17415)
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+import os
+import sys
+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:
+ package = sys.argv[1]
+except IndexError:
+ raise RuntimeError, "ERROR: Required the package name as argument"
+
+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 '%s-lex-%s, %s-yacc-%s' % (package, lex_tabversion, package,
+ yacc_tabversion)
+finally:
+ shutil.rmtree(tmpdir)
Property changes on: packages/ply/trunk/debian/virtual-packages.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the Python-modules-commits
mailing list