Skip to content

The dependency_finder.python module fails to find all dependencies #409

@apdavison

Description

@apdavison

For example, running on a script with the following import statements:

import numpy as np
import matplotlib
from scipy import ndimage

reports only

  • _distutils_hack
  • numpy
  • packaging
  • setuptools

This is because an Exception is raised during modulefinder.run_script (which Sumatra ignores, since it's better to get some dependencies than none; however, Sumatra should include the information that not all dependencies were captured):

...
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/modulefinder.py:69, in _find_module(name, path)
     65     return None, None, ("", "", _PY_FROZEN)
     67 file_path = spec.origin
---> 69 if spec.loader.is_package(name):
     70     return None, os.path.dirname(file_path), ("", "", _PKG_DIRECTORY)
     72 if isinstance(spec.loader, importlib.machinery.SourceFileLoader):

AttributeError: 'NoneType' object has no attribute 'is_package'

This seems to be related to a known bug related to namespace packages in modulefinder, for which there is a long-standard pull request: python/cpython#29196

Since we don't know when/if this bug will be fixed, it might be worth incorporating a patched copy of modulefinder into Sumatra, although probably not the full solution from the PR since that changes importlib/_bootstrap.py, which I'd rather not mess with.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy