[PATCH] import-checker: exclude dist-packages tree from stdlib as well

Yuya Nishihara yuya at tcha.org
Fri Jul 3 08:48:46 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1435929436 -32400
#      Fri Jul 03 22:17:16 2015 +0900
# Node ID 506956b94ca90eec47dfd7d9746e129bc3ccf884
# Parent  d3d2ba265e17af1d9700e3e99de4d012b1b31ab8
import-checker: exclude dist-packages tree from stdlib as well

On Debian, packaged modules are installed into dist-packages, not to
site-packages. Because of this, if we have mercurial installed, the test
failed as 'mercurial.node' was listed in stdlib_modules:

  testpackage/latesymbolimport.py relative import of stdlib module

https://wiki.debian.org/Python

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -192,7 +192,7 @@ def list_stdlib_modules():
         # of any().
         if not any(libpath.startswith(p) for p in stdlib_prefixes): # no-py24
             continue
-        if 'site-packages' in libpath:
+        if 'site-packages' in libpath or 'dist-packages' in libpath:
             continue
         for top, dirs, files in os.walk(libpath):
             for name in files:
@@ -202,7 +202,7 @@ def list_stdlib_modules():
                         or name.endswith('.pyd')):
                     continue
                 full_path = os.path.join(top, name)
-                if 'site-packages' in full_path:
+                if 'site-packages' in full_path or 'dist-packages' in full_path:
                     continue
                 rel_path = full_path[len(libpath) + 1:]
                 mod = dotted_name_of_path(rel_path)


More information about the Mercurial-devel mailing list