code: def project_import_modules(project_path, ignores):
      """
      copied form pigar req.project_import_modules patching, os.getcwd() is incorrectly used
      """
      modules = ImportedModules()
      try_imports = set()
      local_mods = list()
      ignore_paths = set()
      venv_subdirs = set(
          ("bin", "etc", "include", "lib", "lib64", "share")
      )
      ignore_absolute = []
      if not ignores:
          ignore_paths.add(".git")
      else:
          for path in ignores:
              ignore_paths.add(Path(path).name)
  
      if os.path.isfile(project_path):
          try:
              fake_path = Path(project_path).name
              with open(project_path, "rb") as f:
                  fmodules, try_ipts = file_import_modules(
                      fake_path, f.read()
                  )
                  modules |= fmodules
                  try_imports |= try_ipts
          except Exception:
              pass
      else:
          cur_dir = project_path
          for dirpath, dirnames, files in os.walk(
              os.path.abspath(project_path), followlinks=True
          ):
              # see if we have a parent folder in the ignore list
              if ignore_paths & set(
                  Path(dirpath).relative_to(cur_dir).parts
              ):
                  continue
              # check if we are in a subfolder of ignore list
              if any(
                  True
                  for prefix in ignore_absolute
                  if dirpath.startswith(prefix)
              ):
                  continue
              # Hack detect if this is a virtual-env folder, if so add it to the uignore list
              if set(dirnames) == venv_subdirs:
                  ignore_absolute.append(
                      Path(dirpath).as_posix() + os.sep
                  )
                  continue
  
              py_files = list()
              for fn in files:
                  # C extension.
                  if fn.endswith(".so"):
                      local_mods.append(fn[:-3])
                  # Normal Python file.
                  if fn.endswith(".py"):
                      local_mods.append(fn[:-3])
                      py_files.append(fn)
              if "__init__.py" in files:
                  local_mods.append(os.path.basename(dirpath))
              for file in py_files:
                  try:
                      fpath = os.path.join(dirpath, file)
                      fake_path = (
                          Path(fpath).relative_to(cur_dir).as_posix()
                      )
                      with open(fpath, "rb") as f:
                          fmodules, try_ipts = file_import_modules(
                              fake_path, f.read()
                          )
                          modules |= fmodules
                          try_imports |= try_ipts
                  except Exception:
                      pass
  
      return modules, try_imports, local_mods
  
imports: from __future__ import print_function, division, absolute_import
  import json
  import os
  import sys
  import six
  import fnmatch
  import importlib
  import ast
  import doctest
  import collections
  import functools
  from pathlib2 import Path
  from .utils import parse_git_config
  from .modules import ImportedModules
label_desc: Use image node_id 1 for calling a global function with example usage: project_import_modules(project_path, ignores) and returns: modules,  try_imports,  local_mods