Fix #1105: Cache corrupts exension modules with same basename.

Eg. both `_random.so` and `subpackage._random.so` have been stored as
`random.so` into the cache. Now take the `dist_nm` if available.