Generating hooked curve through "n" number of points with python
import bpy
from mathutils import Vector
cubes = [ob for ob in bpy.context.scene.objects if ob.name.startswith('Cube')]
spline = bpy.context.active_object
length = len(spline.data.splines[0].points)
for i in range(length):
    bpy.ops.curve.select_all(action='DESELECT')
    point = spline.data.splines[0].points[i]
    cube = cubes[i]
    point.select = True
    point.co = Vector((cube.location.x, cube.location.y, cube.location.z, 1))
    cube.select_set(True)
    bpy.ops.object.hook_add_selob(use_bone=False)
    cube.select_set(False)

It's a bit quick and dirty, so here are the preparations you need to do:

The scripts selects the cubes by name, in alphabetical order. If any object in your scene starts with 'Cube' (e.g. Cube.001), it will be added to the cube array. There are more elegant ways to select a group of objects, but this was the simplest one.
You need at least as many cubes as the spline has points.
You need to select the curve and go into Edit Mode before running the script.