From patchwork Sun May 28 13:05:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [05,of,10] import-checker: guess names of C extension modules From: Yuya Nishihara X-Patchwork-Id: 20978 Message-Id: <07e2ebf8603fce9789be.1495976710@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sun, 28 May 2017 22:05:10 +0900 # HG changeset patch # User Yuya Nishihara # Date 1493731698 -32400 # Tue May 02 22:28:18 2017 +0900 # Node ID 07e2ebf8603fce9789bea6c35c70390f14aabf5b # Parent 025a92408cd3ca65b696c49e0621eeb0eb58b5f2 import-checker: guess names of C extension modules Since extension modules aren't included in the list of source files, they need to be populated somehow. Otherwise the import from cext/cffi would be treated as a global one. diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -170,6 +170,16 @@ def fromlocalfunc(modulename, localmods) return False return fromlocal +def populateextmods(localmods): + """Populate C extension modules based on pure modules""" + newlocalmods = set(localmods) + for n in localmods: + if n.startswith('mercurial.pure.'): + m = n[len('mercurial.pure.'):] + newlocalmods.add('mercurial.cext.' + m) + newlocalmods.add('mercurial.cffi._' + m) + return newlocalmods + def list_stdlib_modules(): """List the modules present in the stdlib. @@ -701,7 +711,7 @@ def main(argv): for source_path in argv[1:]: modname = dotted_name_of_path(source_path) localmodpaths[modname] = source_path - localmods = set(localmodpaths) + localmods = populateextmods(localmodpaths) for localmodname, source_path in sorted(localmodpaths.items()): for src, modname, name, line in sources(source_path, localmodname): try: