Patchwork [2,of,2,V2] import-checker: exclude mercurial packages installed into the system path

login
register
mail settings
Submitter Yuya Nishihara
Date July 4, 2015, 2:44 a.m.
Message ID <861d0dbfbe505c4f68d2.1435977875@mimosa>
Download mbox | patch
Permalink /patch/9892/
State Accepted
Headers show

Comments

Yuya Nishihara - July 4, 2015, 2:44 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1435974997 -32400
#      Sat Jul 04 10:56:37 2015 +0900
# Node ID 861d0dbfbe505c4f68d252d0dee35728bf3f3d68
# Parent  b759bd4b1a6b581f95994481fe2dbbc7c5617487
import-checker: exclude mercurial packages installed into the system path

If mercurial was installed into a directory other than the site-packages,
test-module-imports.t failed as 'mercurial.node' was listed in stdlib_modules:

  testpackage/latesymbolimport.py relative import of stdlib module

Instead, we should exclude our packages explicitly.
Matt Mackall - July 7, 2015, 11:44 p.m.
On Sat, 2015-07-04 at 11:44 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1435974997 -32400
> #      Sat Jul 04 10:56:37 2015 +0900
> # Node ID 861d0dbfbe505c4f68d252d0dee35728bf3f3d68
> # Parent  b759bd4b1a6b581f95994481fe2dbbc7c5617487
> import-checker: exclude mercurial packages installed into the system path

These are queued for default, thanks.

Patch

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -192,11 +192,10 @@  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:
-            continue
         for top, dirs, files in os.walk(libpath):
             for i, d in reversed(list(enumerate(dirs))):
-                if not os.path.exists(os.path.join(top, d, '__init__.py')):
+                if (not os.path.exists(os.path.join(top, d, '__init__.py'))
+                    or top == libpath and d in ('hgext', 'mercurial')):
                     del dirs[i]
             for name in files:
                 if name == '__init__.py':