Commits

Ronald Oussoren committed 801652f

modulegraph.find_modules.find_needed_modules did not include subpackages of the packages argument, while claiming it does.

Comments (0)

Files changed (2)

doc/changelog.rst

 Features
 ........
 
+* ``modulegraph.find_modules.find_needed_modules`` claimed to automaticly
+  include subpackages for the "packages" argument as well, but that code
+  didn't work at all.
+
 * Issue #9: The modulegraph script is deprecated, use 
   "python -mmodulegraph" instead.
 

modulegraph/find_modules.py

         # first trim the path (of the head package),
         # then convert directory name in package name,
         # finally push into modulegraph.
+        # FIXME:
+        # 1) Needs to be adjusted for namespace packages in python 3.3
+        # 2) Code is fairly dodgy and needs better tests
         for (dirpath, dirnames, filenames) in os.walk(path):
             if '__init__.py' in filenames and dirpath.startswith(path):
-                package = f + '.' + path[len(path)+1:].replace(os.sep, '.')
-                mf.import_hook(package, None, ["*"])
+                package = f + '.' + dirpath[len(path)+1:].replace(os.sep, '.')
+                if package.endswith('.'):
+                    package = package[:-1]
+                m = mf.import_hook(package, None, ["*"])
+            else:
+                # Exclude subtrees that aren't packages
+                dirnames[:] = []
+
 
     return mf