#NEWLINE# def _CheckRequirements( requirements_file_path ) : #NEWLINE# #INDENT# 'Checks that all package requirements specified in a file are met.\n\n  Args:\n    requirements_file_path: string. Path to a pip requirements file.\n  ' #NEWLINE# with open ( requirements_file_path , 'rb' ) as fp : #NEWLINE# #INDENT# requirements_to_check = [ ( requirements_file_path , deque ( fp . readlines ( ) ) ) ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# while requirements_to_check : #NEWLINE# #INDENT# ( file_path , lines ) = requirements_to_check . pop ( ) #NEWLINE# while lines : #NEWLINE# #INDENT# line = lines . popleft ( ) . strip ( ) #NEWLINE# if line . startswith ( '-r' ) : #NEWLINE# #INDENT# requirements_to_check . append ( ( file_path , lines ) ) #NEWLINE# file_path = os . path . join ( os . path . dirname ( file_path ) , line [ 2 : ] ) #NEWLINE# with open ( file_path , 'rb' ) as fp : #NEWLINE# #INDENT# lines = deque ( fp . readlines ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if line : #NEWLINE# #INDENT# pkg_resources . require ( line ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except ( pkg_resources . DistributionNotFound , pkg_resources . VersionConflict ) as e : #NEWLINE# #INDENT# report = getattr ( e , 'report' , None ) #NEWLINE# err_msg = ( report ( ) if report else str ( e ) ) #NEWLINE# raise errors . Setup . PythonPackageRequirementUnfulfilled ( 'A Python package requirement was not met while checking "{path}": {msg}{linesep}To install required packages, execute the following command:{linesep}pip install -r "{path}"{linesep}To bypass package requirement checks, run PerfKit Benchmarker with the --ignore_package_requirements flag.' . format ( linesep = os . linesep , msg = err_msg , path = requirements_file_path ) )