#NEWLINE# def _install_pkg_latest( env , pkg , args , brew_cmd , ipkgs ) : #NEWLINE# #INDENT# 'Install the latest version of the given package.\n    ' #NEWLINE# short_pkg = pkg . split ( '/' ) [ ( - 1 ) ] #NEWLINE# do_install = True #NEWLINE# is_linked = True #NEWLINE# remove_old = False #NEWLINE# if ( ( pkg in ipkgs [ 'outdated' ] ) or ( short_pkg in ipkgs [ 'outdated' ] ) ) : #NEWLINE# #INDENT# remove_old = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( pkg in ipkgs [ 'current' ] ) or ( short_pkg in ipkgs [ 'current' ] ) ) : #NEWLINE# #INDENT# do_install = False #NEWLINE# ( pkg_version , is_linked ) = _latest_pkg_version ( env , brew_cmd , flags , devel = ( '--devel' in args ) ) #NEWLINE# cur_version = ipkgs [ 'current' ] . get ( pkg , ipkgs [ 'current' ] [ short_pkg ] ) #NEWLINE# if ( ( cur_version != pkg_version ) and ( cur_version . split ( '_' ) [ 0 ] != pkg_version ) ) : #NEWLINE# #INDENT# remove_old = True #NEWLINE# do_install = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if do_install : #NEWLINE# #INDENT# if remove_old : #NEWLINE# #INDENT# env . safe_run ( '{brew_cmd} remove --force {short_pkg}' . format ( ** locals ( ) ) ) #NEWLINE# #UNINDENT# flags = ' ' . join ( args ) #NEWLINE# with settings ( warn_only = True ) : #NEWLINE# #INDENT# cmd = ( '%s %s %s' % ( _get_brew_install_cmd ( brew_cmd , env , pkg ) , flags , pkg ) ) #NEWLINE# with _custom_unlink ( env , brew_cmd , pkg ) : #NEWLINE# #INDENT# result = env . safe_run_output ( cmd ) #NEWLINE# #UNINDENT# if ( result . failed and ( not ( result . find ( 'Could not symlink' ) > 0 ) ) ) : #NEWLINE# #INDENT# sys . tracebacklimit = 1 #NEWLINE# raise ValueError ( ( ( ( 'Failed to install brew formula: %s\n' % pkg ) + 'To debug, please try re-running the install command with verbose output:\n' ) + cmd . replace ( 'brew install' , 'brew install -v' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# env . safe_run ( ( '%s link --overwrite %s' % ( brew_cmd , pkg ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not is_linked ) : #NEWLINE# #INDENT# env . safe_run ( ( '%s link --overwrite %s' % ( brew_cmd , pkg ) ) )