hmm ... OK, no, I've misunderstood you there.  This isn't used to set sys.local_libdir, is it ?
It's used to ensure we don't load a file repeatedly.  Using realpath ensures we don't load it repeatedly, even if it's referenced by symlinks from several places.  I'm not sure that's right, essentially because of the same use-case I describe above: if each of the symlinks to the file is read with a different value for "the directory I'm in", it can use that variable to apply a common set of promises to each of the directories thus referenced.