Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,28 @@
# pip <= 9.0.3
from pip.req import parse_requirements

try:
# pip >= 10
from pip._internal.download import PipSession
except ImportError:
# pip <= 9.0.3
from pip.download import PipSession
PipSession = None
download_module_names = [ "pip._internal.network.download", "pip._internal.download", "pip.download" ]
for module_name in download_module_names:
try:
PipSession = __import__(f'{module_name}', globals(), locals(), [None], 0).PipSession
break
except ImportError:
pass

if not PipSession:
raise ImportError("Could not find PipSession")


def get_requirements():
requirements = parse_requirements(
os.path.join(os.path.dirname(__file__), "requirements.txt"),
session=PipSession())
return [str(req.req) for req in requirements]

try:
return [str(req.requirement) for req in requirements]
except AttributeError:
return [str(req.req) for req in requirements]


def read(fname):
Expand Down