Can't UV unwrap a sphere added with Python
Select the Faces.

The Smart UV unwrap (or most UV ops) rely on faces being selected. For objects added via an add mesh primitive operator all verts, and hence faces are selected by default. For meshes created by bmesh the opposite is the case.

Simply select all faces when you create the bmesh and the UV unwrap will work as expected. 

bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, diameter=1)
for f in bm.faces:
    f.select_set(True)


Related:

Smart unwrap using script  (Looks somewhat familiar)

How to UV Unwrap and Scale UVs with Python (while in object mode)?

This way can lose the edit mode toggle and use no operators.

import bpy
from bl_operators.uvcalc_smart_project import main as smart_proj


context = bpy.context
scene = context.scene

meshobs = [o for o in scene.objects if o.type == 'MESH']
for o in meshobs:
    o.select_set(False) 
for o in meshobs:
    context.view_layer.objects.active = o
    o.select_set(True)
    smart_proj(context, 0, 66, 0, True, True)
    o.select_set(False)


I am trying to create a Script that does a Smart UV unwrap of seperate connected parts of a mesh