To facilitate detection of pip in scenarios where parsing JSON isn't
easy but simple string matching is, change the User-Agent to be of
the form "pip/{version} {json}" instead of just "{json}".
The contents of the JSON data has not changed.
This is a rebased final version of a proposed solution to fix
issues #932, #1104 & #1180. Following changes have been done:
* Implemented a new class `PipXmlrpcTransport` using a
contained `PipSession` object.
* Modified the `pip/commands/search.py` to make use of the
`PipXmlrpcTransport` class.
* Properly initialized options for testing `SearchCommand`:
- Changed `options_mock` to an `options` object built from
`parse_args`, to properly initialize default options.
* Deprecates the --download-cache option & removes the download
cache code.
* Removes the in memory page cache on the index
* Uses CacheControl to cache all cacheable HTTP requests to the
filesystem.
* Properly handles CacheControl headers for unconditional
caching.
* Will use ETag and Last-Modified headers to attempt to do a
conditional HTTP request to speed up cache misses and turn
them into cache hits.
* Removes some concurrency unsafe code in the download cache
accesses.
* Uses a Cache-Control request header to limit the maximum
length of time a cache is valid for.
* Adds pip.appdirs to handle platform specific application
directories such as cache, config, data, etc.
If Pip is using an index url that starts with http:// or https://, and
it gets a 404, it does Magic(TM) to figure out what the real name of the
package is. The code looks as though it's intended to do this for
file:// urls as well - but it doesn't, because nothing catches the
OSError that gets raised when the first stat fails.
In order to let this failure be handled and let the usual logic kick in,
set the response status to 404 and let the error bubble up.
Add a 'retry' option which allows to configure how many
retries pip should make before giving up on HTTP request.
When the retries count is specified by user, its value is
passed to HTTPAdapter from requests which handles all
the underlying operations.
Using sys.exc_info()[1] is a hack that was used to use a shared
source approach to Python 3.x support that also included versions
of Python that didn't include the except ... as exc: construction.
Pip no longer supports any of these versions of Python so we can
remove it.
Without this, "pip install" crashes when encountering symlinks that
point to external paths. The culprit is "shutil.copytree()", which
throws an error in such cases if the "symlinks" parameter is not set to
"True".
This fixes#1006.