`readlink -f` won't work on Mac. Fixed it.

Due to an issue of Mac. The GNU `readlink -f` won't work on it. I tried to fix it with a python inline string function.
`os.path.realpath` will resolve a link's real path. This should work on all platforms.