Skip to content

Commit

Permalink
Modulegraph: Fix not matching filetypes ending in cpython-37m.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
springermac committed Jun 21, 2019
1 parent d740524 commit 864dbf0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions PyInstaller/lib/modulegraph/modulegraph.py
Expand Up @@ -89,6 +89,9 @@
filetype: (filetype, open_mode, imp_type)
for filetype, open_mode, imp_type in imp.get_suffixes()
}
# Reverse sort by length so when comparing filenames the longest match first
_IMPORTABLE_FILETYPE_EXTS = sorted(_IMPORTABLE_FILETYPE_TO_METADATA,
key=lambda p: len(p), reverse=True)
"""
Dictionary mapping the filetypes of importable files to the 3-tuple of metadata
describing such files returned by the `imp.get_suffixes()` function whose first
Expand Down Expand Up @@ -3091,8 +3094,16 @@ def _find_module_path(self, fullname, module_name, search_dirs):
# Else, this is either a module or C extension.
else:
# In either case, this path must have a filetype.
filetype = os.path.splitext(pathname)[1]
if not filetype:
# os.path.splitext won't work here since we sometimes need
# to match more than just the file extension.
filetype = [filetype
for filetype in _IMPORTABLE_FILETYPE_EXTS
if pathname.endswith(filetype)]
if filetype:
# at least one extension matched,
# pick the first (longest) one
filetype = filetype[0]
else:
raise ImportError(
'Non-package module %r path %r has no filetype' % (module_name, pathname))

Expand Down

0 comments on commit 864dbf0

Please sign in to comment.