Patchwork import-checker: handle standard modules with arch in the filename

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 7, 2014, 2:02 a.m.
Message ID <ae30cadae57eb52d23a7.1391738520@localhost.localdomain>
Download mbox | patch
Permalink /patch/3497/
State Accepted
Commit 466e4c574db0ca1faf699fa1139423fd7c85a1c3
Headers show

Comments

Mads Kiilerich - Feb. 7, 2014, 2:02 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1391738386 -3600
#      Fri Feb 07 02:59:46 2014 +0100
# Node ID ae30cadae57eb52d23a74b5c1fd576b025f3eeed
# Parent  9fe578297b5c3f63512cc003c6fcdca85fa66435
import-checker: handle standard modules with arch in the filename

Installations with module names like
/usr/lib/python2.7/lib-dynload/bz2.x86_64-linux-gnu.so occurs in the wild.

Let's just ignore everything after first '.' when guessing the Python module
name.
Matt Mackall - Feb. 7, 2014, 2:20 a.m.
On Fri, 2014-02-07 at 03:02 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1391738386 -3600
> #      Fri Feb 07 02:59:46 2014 +0100
> # Node ID ae30cadae57eb52d23a74b5c1fd576b025f3eeed
> # Parent  9fe578297b5c3f63512cc003c6fcdca85fa66435
> import-checker: handle standard modules with arch in the filename
> 
> Installations with module names like
> /usr/lib/python2.7/lib-dynload/bz2.x86_64-linux-gnu.so occurs in the wild.

Thanks, this fixes my earlier problem. Queued for default.

Patch

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -17,7 +17,7 @@  def dotted_name_of_path(path):
     'zlib'
     """
     parts = path.split('/')
-    parts[-1] = parts[-1][:-3] # remove .py
+    parts[-1] = parts[-1].split('.', 1)[0] # remove .py and .so and .ARCH.so
     if parts[-1].endswith('module'):
         parts[-1] = parts[-1][:-6]
     return '.'.join(parts)