Generate rig from mesh
If you have one connected edge loop, you can use this script.



The mesh object has to be selected before executing the script.

import bpy

def CreateBoneChainFromVertices():
    obj = bpy.context.active_object
    if (None == obj):
        return

    if (obj.type != 'MESH'):
        return
    bpy.ops.object.mode_set(mode='OBJECT')

    edgesA = []
    edgesB = []
    for i in range(len(obj.data.edges)):
        ver = obj.data.edges[i].vertices
        edgesA.append(ver[0])
        edgesB.append(ver[1])

    chain = []
    chain.append(edgesA[0])
    while(True):
        current = chain[len(chain)-1]
        if current in edgesA:
            idx = edgesA.index(current)
            next = edgesB[idx]
            del edgesA[idx]
            del edgesB[idx]
            chain.append(next)
        elif current in edgesB:
            idx = edgesB.index(current)
            next = edgesA[idx]
            del edgesA[idx]
            del edgesB[idx] 
            chain.append(next)
        else:
            if (chain[0] in edgesA) or (chain[0] in edgesB):
                chain = list(reversed(chain))
            else:
                break

    amt = bpy.data.armatures.new(obj.name + "_vBones")
    rig = bpy.data.objects.new(obj.name + '_vRig', amt)
    bpy.context.collection.objects.link(rig)
    bpy.context.view_layer.objects.active = rig
    bpy.context.view_layer.update()

    print(chain, "here we go")
    bpy.ops.object.editmode_toggle()
    for i in range(0, len(chain) - 1):
        bone = amt.edit_bones.new(str(i + 1))
        bone.head = obj.data.vertices[chain[i]].co
        bone.tail = obj.data.vertices[chain[i + 1]].co
    for i in range(0, len(amt.edit_bones) - 1):
        amt.edit_bones[i + 1].parent = amt.edit_bones[i]
        amt.edit_bones[i + 1].use_connect = True
    bpy.ops.object.editmode_toggle()

CreateBoneChainFromVertices()