From b70b55bf92d81b869c8a2f8f66c9b4edc88ae053 Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Thu, 2 Aug 2018 09:23:58 -0400 Subject: [PATCH] Fix Pip-18 Incompatibilities --- important/parse.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/important/parse.py b/important/parse.py index 093fbc5..e93a2f0 100644 --- a/important/parse.py +++ b/important/parse.py @@ -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]?$') @@ -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(