Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #874 from hltbra/remote-reqs-py3-pull-request

Fix issue #760: broken external requirements on Python 3
  • Loading branch information...
commit 5256d573fd6c1081448ca21b016834255bbf2831 2 parents 8979b3f + bbed75e
@pnasrat pnasrat authored
View
7 pip/backwardcompat/__init__.py
@@ -59,6 +59,9 @@ def console_to_str(s):
def fwrite(f, s):
f.buffer.write(b(s))
+ def get_http_message_param(http_message, param, default_value):
+ return http_message.get_param(param, default_value)
+
bytes = bytes
string_types = (str,)
raw_input = input
@@ -87,6 +90,10 @@ def console_to_str(s):
def fwrite(f, s):
f.write(s)
+ def get_http_message_param(http_message, param, default_value):
+ result = http_message.getparam(param)
+ return result or default_value
+
bytes = str
string_types = (basestring,)
reduce = reduce
View
7 pip/download.py
@@ -10,7 +10,7 @@
import tempfile
from pip.backwardcompat import (xmlrpclib, urllib, urllib2, httplib,
- urlparse, string_types, ssl)
+ urlparse, string_types, ssl, get_http_message_param)
if ssl:
from pip.backwardcompat import match_hostname, CertificateError
from pip.exceptions import InstallationError, PipError, NoSSLError
@@ -32,7 +32,7 @@
def get_file_content(url, comes_from=None):
"""Gets the content of a file; it may be a filename, file: URL, or
- http: URL. Returns (location, content)"""
+ http: URL. Returns (location, content). Content is unicode."""
match = _scheme_re.search(url)
if match:
scheme = match.group(1).lower()
@@ -54,7 +54,8 @@ def get_file_content(url, comes_from=None):
else:
## FIXME: catch some errors
resp = urlopen(url)
- return geturl(resp), resp.read()
+ encoding = get_http_message_param(resp.headers, 'charset', 'utf-8')
+ return geturl(resp), resp.read().decode(encoding)
try:
f = open(url)
content = f.read()
View
11 tests/test_requirements.py
@@ -29,6 +29,17 @@ def test_requirements_file():
assert result.files_created[env.site_packages/fn].dir
+def test_remote_reqs():
+ """
+ Test installing from a remote requirements file.
+ """
+ env = reset_env()
+ result = run_pip(
+ 'install', '--download', env.scratch_path, '-r',
+ 'https://gist.github.com/hltbra/5271779/raw/pip-test-package-requirements.txt')
+ assert result.files_created, result.files_created
+
+
def test_schema_check_in_requirements_file():
"""
Test installing from a requirements file with an invalid vcs schema..
Please sign in to comment.
Something went wrong with that request. Please try again.