global_namespace = {'__file__': filepath, '__name__': '__main__'}
with open(filepath, 'rb') as file:
    exec(compile(file.read(), filepath, 'exec'), global_namespace)
exec_full('/path/to/somefile.py')
Альтернатива execfile в Python 3?