def get_required_packages(file_contents):
 if (file_contents.count(INST_REQS_KWARG) != 1):
  raise ValueError('Expected only one use of keyword', INST_REQS_KWARG, file_contents)
 keyword_stmt = ((INST_REQS_KWARG + '=') + REQ_VAR)
 if (file_contents.count(keyword_stmt) != 1):
  raise ValueError('Expected keyword to be set with variable', INST_REQS_KWARG, REQ_VAR, file_contents)
 (_, reqs_section, _) = file_contents.split(REQ_VAR)
 reqs_begin = reqs_section.index('[')
 reqs_end = (reqs_section.index(']') + 1)
 reqs_list_text = reqs_section[reqs_begin:reqs_end]
 requirements = ast.literal_eval(reqs_list_text)
 result = []
 for required in requirements:
  parts = required.split()
  result.append(parts[0])
 return result

def get_required_packages ( file_contents ) : if ( file_contents . count ( INST_REQS_KWARG ) != 1 ) : raise ValueError ( 'Expected only one use of keyword' , INST_REQS_KWARG , file_contents ) keyword_stmt = ( ( INST_REQS_KWARG + '=' ) + REQ_VAR ) if ( file_contents . count ( keyword_stmt ) != 1 ) : raise ValueError ( 'Expected keyword to be set with variable' , INST_REQS_KWARG , REQ_VAR , file_contents ) ( _ , reqs_section , _ ) = file_contents . split ( REQ_VAR ) reqs_begin = reqs_section . index ( '[' ) reqs_end = ( reqs_section . index ( ']' ) + 1 ) reqs_list_text = reqs_section [ reqs_begin : reqs_end ] requirements = ast . literal_eval ( reqs_list_text ) result = [ ] for required in requirements : parts = required . split ( ) result . append ( parts [ 0 ] ) return result
get required packages from a setup .