Workaround for issue #14125.

Explicitly set __env__ and friends for python file templates.
Merge pull request #14352 from hazaelsan/fix_14125

Workaround for issue #14125.