# Path: sumatra/dependency_finder/core.py
# def find_versions_from_versioncontrol(dependencies):
# def find_versions(dependencies, heuristics):
# def find_file(path, current_directory, search_dirs):
#     def __init__(self, name, path=None, version='unknown', diff='', source=None):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
# class BaseDependency(object):
# 
# Path: sumatra/core.py
# def get_encoding():
#     if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
#         encoding = sys.stdout.encoding
#     else:
#         encoding = locale.getpreferredencoding()
#         if encoding == '':  # getpreferredencoding does not guarantee to return an encoding
#             encoding = sys.getdefaultencoding()
#     return encoding


from builtins import str
from modulefinder import Module
from sumatra.dependency_finder import core
from ..core import get_encoding
    from types import ModuleType
    from sumatra import programs
import os
import sys
import textwrap
import warnings
import inspect
import logging
    import textwrap
    import subprocess
    import sys

    def __init__(self, module_name, path, version='unknown', diff='', source=None):
        super(Dependency, self).__init__(module_name, path, version, diff, source)

    @classmethod
    def from_module(cls, module, executable_path):
        """Create from modulefinder.Module instance."""
        path = os.path.realpath(module.__path__[0])  # resolve any symbolic links
        if len(module.__path__) > 1:
            raise Exception("This is not supposed to happen. Please tell the package developers about this.")  # or I could figure out for myself when this could happen
        return cls(module.__name__, module.__path__[0])


def find_imported_packages(filename, executable_path, debug=0, exclude_stdlib=True):
    """
    Find all imported top-level packages for a given Python file.

    We cannot assume that the version of Python being used to run Sumatra is the
    same as that used to run the simulation/analysis. Therefore we need to run
    all the dependency finding and version checking in a subprocess with the
    correct version of Python.
    """
    # Actually, we could check whether executable_path matches sys.executable, and
    # then do it in this process. On the other hand, the dependency finding
    # could run in parallel with the simulation (good for multicore): we could
    # move setting of dependencies to after the simulation, rather than having it
    # in record.register()

    # HACK Added excludes=['jinja2.asyncsupport']
    script = textwrap.dedent("""

# Path: sumatra/dependency_finder/core.py
# def find_versions_from_versioncontrol(dependencies):
# def find_versions(dependencies, heuristics):
# def find_file(path, current_directory, search_dirs):
#     def __init__(self, name, path=None, version='unknown', diff='', source=None):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
# class BaseDependency(object):
# 
# Path: sumatra/core.py
# def get_encoding():
#     if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
#         encoding = sys.stdout.encoding
#     else:
#         encoding = locale.getpreferredencoding()
#         if encoding == '':  # getpreferredencoding does not guarantee to return an encoding
#             encoding = sys.getdefaultencoding()
#     return encoding


# Path: sumatra/dependency_finder/python.py
from builtins import str
from modulefinder import Module
from sumatra.dependency_finder import core
from ..core import get_encoding
    from types import ModuleType
    from sumatra import programs
import os
import sys
import textwrap
import warnings
import inspect
import logging
    import textwrap
    import subprocess
    import sys


    def __init__(self, module_name, path, version='unknown', diff='', source=None):
        super(Dependency, self).__init__(module_name, path, version, diff, source)

    @classmethod
    def from_module(cls, module, executable_path):
        """Create from modulefinder.Module instance."""
        path = os.path.realpath(module.__path__[0])  # resolve any symbolic links
        if len(module.__path__) > 1:
            raise Exception("This is not supposed to happen. Please tell the package developers about this.")  # or I could figure out for myself when this could happen
        return cls(module.__name__, module.__path__[0])


def find_imported_packages(filename, executable_path, debug=0, exclude_stdlib=True):
    """
    Find all imported top-level packages for a given Python file.

    We cannot assume that the version of Python being used to run Sumatra is the
    same as that used to run the simulation/analysis. Therefore we need to run
    all the dependency finding and version checking in a subprocess with the
    correct version of Python.
    """
    # Actually, we could check whether executable_path matches sys.executable, and
    # then do it in this process. On the other hand, the dependency finding
    # could run in parallel with the simulation (good for multicore): we could
    # move setting of dependencies to after the simulation, rather than having it
    # in record.register()

    # HACK Added excludes=['jinja2.asyncsupport']
    script = textwrap.dedent("""

        from modulefinder import ModuleFinder