Fix multiple execution of python do ... end blocks

Only run the `python do ... end` loop once even if
multiple `depends_on :python => 'module-name'` are
present.
Dart 24898

Closes #21236.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>