diff --git a/lib/poise_python/resources/python_package.rb b/lib/poise_python/resources/python_package.rb index 059642f..8b8f70c 100644 --- a/lib/poise_python/resources/python_package.rb +++ b/lib/poise_python/resources/python_package.rb @@ -50,7 +50,11 @@ module PythonPackage # Pip 10 moved all internals to their own package. from pip._internal.commands import InstallCommand from pip._internal.index import PackageFinder - from pip._internal.req import InstallRequirement + try: + # Pip 18.1 moved from_line to the constructors + from pip._internal.req.constructors import install_req_from_line + except ImportError: + from pip._internal.req import InstallRequirement packages = {} cmd = InstallCommand() @@ -73,7 +77,10 @@ module PythonPackage finder = PackageFinder(**finder_options) find_all = getattr(finder, 'find_all_candidates', getattr(finder, '_find_all_versions', None)) for arg in args: - req = InstallRequirement.from_line(arg) + try: + req = install_req_from_line(arg) + except NameError: + req = InstallRequirement.from_line(arg) found = finder.find_requirement(req, True) all_candidates = find_all(req.name) candidate = [c for c in all_candidates if c.location == found]