Problem with Cube project bpy

Good Morning Blender Artists
I wanted to ask something. I was trying to use the bpy.ops.uv.cube_project function but I run with an issue.
Every time I use this function on a script, got the following output (I am using also the bpy.ops.uv.pack_islands function).


But, when I use the cube_project function on the visualizer i got the following output

As I mentioned before, I tried using bpy.ops.uv.pack_islands to see if the uv islands wouldn’t be overlapped but at the end I didn’t get what i was specting.

Therefore, I’m here to ask someone has a solution for this.
pd: Here is my piece of code that I use to get the first output that i got.

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type="FACE")
bpy.ops.mesh.select_all(action="SELECT")
  

func(scale_to_bounds=True)
bpy.ops.uv.select_all(action="SELECT")
bpy.ops.uv.pack_islands(rotate=False, margin=0.02)

bpy.ops.object.mode_set(mode="OBJECT")

Thank you, for reading