Setting/overriding context for rigid body bake
bpy.ops.ptcache.bake(bake=False) for Rigid Body doesn't work, because it needs the point cache and scene as a context, so:

override = {'scene': bpy.context.scene,
            'point_cache': bpy.context.scene.rigidbody_world.point_cache}
# bake to current frame
bpy.ops.ptcache.bake(override, bake=False)