Borrow code from PyInstaller project

$ pyinstaller git:(develop) ✗ git rev-parse HEAD
eb071deb8727340bca2872e92cb4745648825fd8