[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#592414: [new check] Warn about Python extension modules linked to libpythonX.Y



tags 592414 + patch
thanks

* Jakub Wilk <jwilk@debian.org>, 2010-08-09, 23:02:
Public Python extension modules, i.e. *.so files in one of these directories:

  /usr/lib/pyshared/pythonX.Y/
  /usr/lib/python-support/PACKAGENAME/pythonX.Y/
  /usr/lib/pythonX.Y/site-packages/
  /usr/lib/pythonX.Y/dist-packages/

should not be linked to libpythonX.Y. Such linkage is not necessary for a module to work correctly and it causes dpkg-shlibdeps to generate dependencies that are too strict. See e.g. bugs #472314, #445411, #445423, #470290.

There should be also a separate check (with severity:serious) for the case where a module in a pythonX.Y directory is linked with libpythonZ.W for X.Y != Z.W. See e.g. bug #586937.

Patch attached.

--
Jakub Wilk
diff --git a/checks/python b/checks/python
new file mode 100644
--- /dev/null
+++ b/checks/python
@@ -0,0 +1,74 @@
+# python -- lintian check script -*- perl -*-
+#
+# Copyright © 2011 Jakub Wilk
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::python;
+
+use strict;
+use warnings;
+
+use Lintian::Tags qw(tag);
+
+my $py_extension = qr{
+^ (?:
+  usr/lib/pyshared/python(2\.\d+)/.*
+| usr/lib/python(2\.\d+)/(?:site|dist)-packages/.*
+| usr/lib/python-support/(?:[^/]+)/python(2\.\d+)/.*
+| usr/lib/python3/dist-packages/.*-(\d+)mu
+) \.so $
+}x;
+
+sub run {
+
+my ($pkg, $type, $info) = @_;
+
+my $index = $info->index;
+my $objdump = $info->objdump_info;
+my @linked_with_libpython = ();
+my $seen_wrong_version = 0;
+
+for my $file (@{$info->sorted_index}) {
+    next if $index->{$file}->{link};
+    if (my @pyversion = ($file =~ $py_extension)) {
+        my ($pyversion) = grep { defined $_ } @pyversion;
+        $pyversion =~ s,^(\d)(\d+)$,$1.$2,;
+        for my $needed (@{$objdump->{$file}->{NEEDED}}) {
+            if ($needed =~ m,^libpython(\d\.\d+)\.so,) {
+                my $libpython = $1;
+                if ($libpython ne $pyversion) {
+                    $seen_wrong_version = 1;
+                    tag 'python-extension-compiled-for-wrong-version', $libpython, $file;
+                } else {
+                    push @linked_with_libpython, $file;
+                }
+            }
+        }
+    }
+}
+unless ($seen_wrong_version) {
+    for my $file (@linked_with_libpython) {
+        tag 'python-extension-linked-with-libpython', $file;
+    }
+}
+
+}
+
+1;
+
+# vim:syntax=perl ts=4 sw=4 et
diff --git a/checks/python.desc b/checks/python.desc
new file mode 100644
--- /dev/null
+++ b/checks/python.desc
@@ -0,0 +1,21 @@
+Check-Script: python
+Author: Jakub Wilk <jwilk@debian.org>
+Abbrev: py
+Type: binary
+Info: This looks for common mistakes in Python binary packages.
+Needs-Info: index, objdump-info
+
+Tag: python-extension-compiled-for-wrong-version
+Severity: serious
+Certainty: certain
+Info: The Python extension module was installed in a directory for a different
+ Python version that it was compiled for.  Different Python versions are not
+ binary-compatible.
+
+Tag: python-extension-linked-with-libpython
+Severity: wishlist
+Certainty: certain
+Info: In Debian, Python extension modules don't need to be linked with
+ libpython<i>X</i>.<i>Y</i>.  Linking to libpython<i>X</i>.<i>Y</i> makes
+ dpkg-shlibdeps generate needlessly strict dependencies.
+Ref: python-policy 2.1
diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile
--- a/profiles/debian/main.profile
+++ b/profiles/debian/main.profile
@@ -6,6 +6,6 @@
  debhelper, debian-readme, debian-source-dir, description, duplicate-files,
  fields, filename-length, files, huge-usr-share, infofiles, init.d, java,
  lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
- po-debconf, rules, scripts, shared-libs, source-copyright, standards-version,
- symlinks, version-substvars, watch-file
+ po-debconf, python, rules, scripts, shared-libs, source-copyright,
+ standards-version, symlinks, version-substvars, watch-file
 

Reply to: