diff --git a/setup.py b/setup.py index 16fd185..1e622d3 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,14 @@ except ImportError: # It is quick hack to support pip 10 that has changed its internal # structure of the modules. - from pip._internal.download import PipSession + # Further hack - seems like pip 20 and later does not support + # pip._internal.download anymore. It appears as though + # parse_requirements (used below) does not need a valid PipSession. + # Any value seems to work. So hack this even more. + try: + from pip._internal.download import PipSession + except ImportError: + PipSession = object from pip._internal.req.req_file import parse_requirements @@ -22,9 +29,12 @@ def get_requirements(source): """ install_reqs = parse_requirements(filename=source, session=PipSession()) - - return [str(ir.req) for ir in install_reqs] - + # pip 20 changed ParsedRequirement.req to ParsedRequirement.requirement. + try: + requirements = [str(ir.req) for ir in install_reqs] + except AttributeError: + requirements = [str(ir.requirement) for ir in install_reqs] + return requirements setup( packages=find_packages(),