Skip to content

Commit

Permalink
Fix Pip-18 Incompatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
kojiromike committed Aug 2, 2018
1 parent a322ca0 commit b70b55b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions important/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

import pip

from pip.commands.show import search_packages_info
from pip.req import parse_requirements as pip_parse_requirements
try:
from pip.commands.show import search_packages_info
from pip.req import parse_requirements as pip_parse_requirements
except ImportError:
from pip._internal.commands.show import search_packages_info
from pip._internal.req import parse_requirements as pip_parse_requirements


RE_SHEBANG = re.compile('^#![^\n]*python[0-9]?$')
Expand Down Expand Up @@ -117,8 +121,12 @@ def parse_dir_imports(current_directory, exclusions=None):


def parse_requirements(filename):
requirements = pip_parse_requirements(filename,
session=pip.download.PipSession())
try:
requirements = pip_parse_requirements(filename,
session=pip.download.PipSession())
except AttributeError:
requirements = pip_parse_requirements(filename,
session=pip._internal.download.PipSession())
for requirement in requirements:
if not requirement.name:
raise ValueError(
Expand Down

0 comments on commit b70b55b

Please sign in to comment.