Inspired by this excellent question, I recently put together a script that tries to do this. You can find it on github at pyqver.
It’s reasonably complete but there are some aspects that are not yet handled (as mentioned in the README file). Feel free to fork and improve it!