浏览代码

Better error message when failing to copy a namespace package

Thomas Kluyver 7 年之前
父节点
当前提交
955c3b0f11
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 1 0
      doc/releasenotes.rst
  2. 6 2
      nsist/copymodules.py

+ 1 - 0
doc/releasenotes.rst

@@ -12,6 +12,7 @@ above. For 'installer' format Python and older Python versions, use Pynsist 1.x
   to be used without admin access.
 * Get wheels for the installer from local directories, by listing the
   directories in ``extra_wheel_sources`` in the ``[Include]`` section.
+* Better error message when copying fails on a namespace package.
 
 Version 1.12
 ------------

+ 6 - 2
nsist/copymodules.py

@@ -109,9 +109,13 @@ class ModuleCopier:
         and extract modules and packages from appropriately structured zip
         files.
         """
-        loader = importlib.find_loader(modname, self.path)
+        spec = importlib.machinery.PathFinder.find_spec(modname, self.path)
+        if spec is None:
+            raise ImportError('Could not find %r' % modname)
+        loader = spec.loader
         if loader is None:
-            raise ImportError('Could not find %s' % modname)
+            raise ImportError('Cannot bundle namespace package %r' % modname)
+
         pkg = loader.is_package(modname)
 
         if isinstance(loader, importlib.machinery.ExtensionFileLoader):