Show More
@@ -22,20 +22,47 b'' | |||
|
22 | 22 | from setuptools import setup, find_packages |
|
23 | 23 | |
|
24 | 24 | import os |
|
25 | import re | |
|
25 | 26 | import sys |
|
26 | 27 | import pkgutil |
|
27 | 28 | import platform |
|
28 | 29 | import codecs |
|
29 | 30 | |
|
30 | try: # for pip >= 10 | |
|
31 | import pip | |
|
32 | ||
|
33 | pip_major_version = int(pip.__version__.split(".")[0]) | |
|
34 | if pip_major_version >= 20: | |
|
31 | 35 | from pip._internal.req import parse_requirements |
|
32 | except ImportError: # for pip <= 9.0.3 | |
|
36 | from pip._internal.network.session import PipSession | |
|
37 | elif pip_major_version >= 10: | |
|
38 | from pip._internal.req import parse_requirements | |
|
39 | from pip._internal.download import PipSession | |
|
40 | else: | |
|
33 | 41 | from pip.req import parse_requirements |
|
42 | from pip.download import PipSession | |
|
43 | ||
|
34 | 44 | |
|
35 | try: # for pip >= 10 | |
|
36 | from pip._internal.download import PipSession | |
|
37 | except ImportError: # for pip <= 9.0.3 | |
|
38 | from pip.download import PipSession | |
|
45 | def get_package_name(req_object): | |
|
46 | package_name = None | |
|
47 | try: | |
|
48 | from pip._internal.req.constructors import install_req_from_parsed_requirement | |
|
49 | except ImportError: | |
|
50 | install_req_from_parsed_requirement = None | |
|
51 | ||
|
52 | # In 20.1 of pip, the requirements object changed | |
|
53 | if hasattr(req_object, 'req'): | |
|
54 | package_name = req_object.req.name | |
|
55 | ||
|
56 | if package_name is None: | |
|
57 | if install_req_from_parsed_requirement: | |
|
58 | package = install_req_from_parsed_requirement(req_object) | |
|
59 | package_name = package.req.name | |
|
60 | ||
|
61 | if package_name is None: | |
|
62 | # fallback for older pip | |
|
63 | package_name = re.split('===|<=|!=|==|>=|~=|<|>', req_object.requirement)[0] | |
|
64 | ||
|
65 | return package_name | |
|
39 | 66 | |
|
40 | 67 | |
|
41 | 68 | if sys.version_info < (2, 7): |
@@ -63,14 +90,15 b' def _get_requirements(req_filename, excl' | |||
|
63 | 90 | parsed = parse_requirements(os.path.join(here, req_filename)) |
|
64 | 91 | |
|
65 | 92 | requirements = [] |
|
66 | for ir in parsed: | |
|
67 | if ir.req and ir.name not in exclude: | |
|
68 | requirements.append(str(ir.req)) | |
|
93 | for int_req in parsed: | |
|
94 | req_name = get_package_name(int_req) | |
|
95 | if req_name not in exclude: | |
|
96 | requirements.append(req_name) | |
|
69 | 97 | return requirements + extras |
|
70 | 98 | |
|
71 | 99 | |
|
72 | 100 | # requirements extract |
|
73 |
setup_requirements = ['PasteScript' |
|
|
101 | setup_requirements = ['PasteScript'] | |
|
74 | 102 | install_requirements = _get_requirements( |
|
75 | 103 | 'requirements.txt', exclude=['setuptools', 'entrypoints']) |
|
76 | 104 | test_requirements = _get_requirements( |
General Comments 0
You need to be logged in to leave comments.
Login now