Fix dirname issues with a python script