A somewhat better solution for the libpython.so detection saga.
Unfortunately it has not presented itself and had to be painfully
extracted from a series of trial and error experiments. No living
beings were harmed in the process, though.
Many thanks to Paul for the help with testing this.