Make setup.py compatible with newer pip versions.

This commit is contained in:
Antoine Nguyen
2020-05-06 14:42:48 +02:00
parent 559519d43a
commit 5f2fbb2b75
2 changed files with 14 additions and 5 deletions
-2
View File
@@ -103,8 +103,6 @@ This version drops Python 2 support.
existing virtual environment and replace it by the new one so you
won't have to modify your configuration files.
You will also need to upgrade your pip version to 20.0.2 or newer.
1.14.0
======
+14 -3
View File
@@ -9,7 +9,11 @@ https://packaging.python.org/en/latest/distributing.html
from os import path
from pip._internal.req import parse_requirements
try:
from pip.req import parse_requirements
except ImportError:
# pip >= 10
from pip._internal.req import parse_requirements
from setuptools import find_packages, setup
@@ -19,7 +23,14 @@ def get_requirements(requirements_file):
requirements = []
if path.isfile(requirements_file):
for req in parse_requirements(requirements_file, session="hack"):
requirements.append("%s" % req.requirement)
try:
if req.requirements.match_markers():
requirements.append("%s;%s" % (req.req, req.markers))
else:
requirements.append("%s" % req.req)
except AttributeError:
# pip >= 20.0.2
requirements.append(req.requirement)
return requirements
@@ -45,7 +56,7 @@ if __name__ == "__main__":
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.2",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: ISC License (ISCL)",
"Operating System :: OS Independent",