Update dist_utils.py so it doesn't depend on internal pip methods.
This way it works with all recent pip versions.
@@ -27,31 +27,18 @@ PY3 = sys.version_info[0] == 3
if PY3:
text_type = str
else:
- text_type = unicode
+ text_type = unicode # NOQA
GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python'
try:
import pip
- from pip import __version__ as pip_version
except ImportError as e:
print('Failed to import pip: %s' % (text_type(e)))
print('')
print('Download pip:\n%s' % (GET_PIP))
sys.exit(1)
-try:
- # pip < 10.0
- from pip.req import parse_requirements
-except ImportError:
- # pip >= 10.0
-
- try:
- from pip._internal.req.req_file import parse_requirements
- except ImportError as e:
- print('Failed to import parse_requirements from pip: %s' % (text_type(e)))
- print('Using pip: %s' % (str(pip_version)))
- sys.exit(1)
__all__ = [
'check_pip_version',
@@ -80,12 +67,19 @@ def fetch_requirements(requirements_file_path):
"""
links = []
reqs = []
- for req in parse_requirements(requirements_file_path, session=False):
- # Note: req.url was used before 9.0.0 and req.link is used in all the recent versions
- link = getattr(req, 'link', getattr(req, 'url', None))
- if link:
- links.append(str(link))
- reqs.append(str(req.req))
+
+ with open(requirements_file_path, 'r') as fp:
+ for line in fp.readlines():
+ line = line.strip()
+
+ if line.startswith('#') or not line:
+ continue
+
+ if line.startswith('git+'):
+ links.append(line)
+ else:
+ reqs.append(line)
+
return (reqs, links)
