def METHOD_NAME(protosrc, dirname):
    '''Try to build a .proto file for python-protobuf.
    Returns True if successful.
    '''
    cmd = [
        "protoc",
        "--python_out={}".format(dirname),
        protosrc,
        "-I={}".format(dirname),
    ]
    if has_grpcio_protoc():
        # grpcio-tools has an extra CLI argument
        # from grpc.tools.protoc __main__ invocation.
        _builtin_proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
        cmd.append("-I={}".format(_builtin_proto_include))
    try:
        invoke_protoc(argv=cmd)
    except:
        sys.stderr.write("Failed to build nanopb_pb2.py: " + ' '.join(cmd) + "\n")
        sys.stderr.write(traceback.format_exc() + "\n")
        return False
    return True