From eddafd17f2fa650c0812b320805e2f0fb0d07632 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/important/parse.py b/important/parse.py index 093fbc5..2f9ded1 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,11 @@ def parse_dir_imports(current_directory, exclusions=None): def parse_requirements(filename): - requirements = pip_parse_requirements(filename, - session=pip.download.PipSession()) + try: + pip_session = pip.download.PipSession() + except AttributeError: + pip_session = pip._internal.download.PipSession() + requirements = pip_parse_requirements(filename, session=pip_session) for requirement in requirements: if not requirement.name: raise ValueError(