Repository: pypa/pip

Issue:
FTP download install failed
``` bash
(venv)ubuntu@box31:~/bex$ pip install ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz
```

``` bash
Downloading/unpacking ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/commands/install.py", line 274, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/req.py", line 1173, in prepare_files
    self.unpack_url(url, location, self.is_download)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/req.py", line 1320, in unpack_url
    retval = unpack_http_url(link, location, self.download_cache, self.download_dir, self.session)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/download.py", line 555, in unpack_http_url
    resp = session.get(target_url, stream=True)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 395, in get
    return self.request('GET', url, **kwargs)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 383, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 481, in send
    adapter = self.get_adapter(url=request.url)
  File "/home/ubuntu/bex/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 526, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
InvalidSchema: No connection adapters were found for 'ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz'

Storing debug log for failure in /home/ubuntu/.pip/pip.log
```



Discussion:
pip --version

```
pip 1.5.2 from /home/ubuntu/bex/venv/local/lib/python2.7/site-packages (python 2.7)
```

I tried the same file using the master HEAD and got the same issue.

It works with pip 1.4.1

Ok, using git bisect I found this commit introduced the issue:
https://github.com/pypa/pip/commit/ff2854a855cb3643a69d8e7c2b020c153107d2b2

I'm running the test like:

```
python pip/runner.py install ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz
```

The looks like it's the result of switching from using the urllib2 library (CacheFTPHandler) to the Requests library which does not provide an FTP Adapter. Until that is available you'll have this problem.

@lucmult You **can** edit your comments – no need to put each update on it's own :)

Hmm, yes this was a result of the switch to requests. However I'm not sure we should continue to support use of ftp urls either way. As far as I'm aware ftp servers to not generally support TLS and without that we lose the ability to securely fetch files from these servers.

Any thoughts @qwcode and @pfmoore ?

Personally, I have no need for ftp. The OP's use case is real, though - xmlsoft.org does only distribute libxml2-python over ftp. But that is a very old version - it's from 2004 as far as I can see.

So I don't have any strong _objection_ to simply documenting that ftp support was discontinued with the move to requests. But if people come up with other genuine use cases, we should be prepared to reconsider (I have had ISPs in the past who only supported ftp hosting, and I can imagine having waned to host packages there)

I found an alternative HTTP link for this package:
`http://xmlsoft.org/sources/python/libxml2-python-2.6.9.tar.gz`

HTTP isn't secure either ;-)

Nope! It's not. But HTTPS is and pip is discouraging the use of HTTP instead of HTTPS :)

@dstufft many hosts out there don't support HTTPS. In fact, this libxml example doesn't support HTTPS.

I agree with @pfmoore suggestion to "fix" this issue by documenting it.


Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -858,7 +858,7 @@ def _handle_fail(req, link, reason, url, level=1, meth=None):
     def _get_content_type(url, session):
         """Get the Content-Type of the given url, using a HEAD request"""
         scheme, netloc, path, query, fragment = urllib_parse.urlsplit(url)
-        if scheme not in ('http', 'https', 'ftp', 'ftps'):
+        if scheme not in ('http', 'https'):
             # FIXME: some warning or something?
             # assertion error?
             return ''


Test patch: