def get_dependency_graph(package_list):
 result = {package: set() for package in package_list}
 for package in package_list:
  setup_file = os.path.join(PROJECT_ROOT, package, 'setup.py')
  with open(setup_file, 'r') as file_obj:
   file_contents = file_obj.read()
  requirements = get_required_packages(file_contents)
  for requirement in requirements:
   if (not requirement.startswith(PACKAGE_PREFIX)):
    continue
   (_, req_package) = requirement.split(PACKAGE_PREFIX)
   req_package = req_package.replace('-', '_')
   result[req_package].add(package)
 return result

def get_dependency_graph ( package_list ) : result = { package : set ( ) for package in package_list } for package in package_list : setup_file = os . path . join ( PROJECT_ROOT , package , 'setup.py' ) with open ( setup_file , 'r' ) as file_obj : file_contents = file_obj . read ( ) requirements = get_required_packages ( file_contents ) for requirement in requirements : if ( not requirement . startswith ( PACKAGE_PREFIX ) ) : continue ( _ , req_package ) = requirement . split ( PACKAGE_PREFIX ) req_package = req_package . replace ( '-' , '_' ) result [ req_package ] . add ( package ) return result
get a directed graph of package dependencies .