Avoid hitting ext4 filename length limit (255 characters) for cached downloads

Previously, the final path component in the downloaded file's URI (including the query string)
was reappropriated verbatim as the name of the file to cache on-disk. However, this could
conflict with the ext4 filesystem's baked-in 255-character filename length limit, resulting in an
`IOError: [Errno 63] File name too long` error.

This commit creates the `shorten_filename` utility function, which splits a filename at a certain
limit, replacing everything after it with a hash, then appending an unhashed suffix. The limit is
determined by the hardcoded maximum and the lengths of the hash and suffix. Filenames shorter than
255 characters are not affected.

I'm not sure if there are any other places pip tries to create a file with a user-supplied name; hopefully, `shorten_filenames` can be used in any that crop up.