Is it possible to set an object's origin with bpy.ops.transform.resize()?
You can use "center_override" for this. Here is the code:

bpy.ops.transform.resize(value=(1, 1, 1), center_override=(42, 42, 42))


Happy Blending! :)