def find_protoc(path=os.environ['PATH']):
    '''
    Traverse a path ($PATH by default) to find the protoc compiler
    '''
    protoc_filename = 'protoc'

    bin_search_paths = path.split(':') or []
    for search_path in bin_search_paths:
        bin_path = os.path.join(search_path, protoc_filename)
        if os.path.isfile(bin_path) and os.access(bin_path, os.X_OK):
            return bin_path

    raise ProtocNotFound("Protobuf compiler not found")
def find_protoc ( path = os . environ [ 'PATH' ] ) : protoc_filename = 'protoc' bin_search_paths = path . split ( ':' ) or [ ] for search_path in bin_search_paths : bin_path = os . path . join ( search_path , protoc_filename ) if os . path . isfile ( bin_path ) and os . access ( bin_path , os . X_OK ) : return bin_path raise ProtocNotFound ( "Protobuf compiler not found" )
Traverse a path ($PATH by default) to find the protoc compiler