##// END OF EJS Templates
setup: synced with rhodecode tools with better compatability on pip versions
super-admin -
r4897:ff5a3ae7 default
parent child Browse files
Show More
@@ -22,20 +22,47 b''
22 from setuptools import setup, find_packages
22 from setuptools import setup, find_packages
23
23
24 import os
24 import os
25 import re
25 import sys
26 import sys
26 import pkgutil
27 import pkgutil
27 import platform
28 import platform
28 import codecs
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 from pip._internal.req import parse_requirements
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 from pip.req import parse_requirements
41 from pip.req import parse_requirements
42 from pip.download import PipSession
43
34
44
35 try: # for pip >= 10
45 def get_package_name(req_object):
36 from pip._internal.download import PipSession
46 package_name = None
37 except ImportError: # for pip <= 9.0.3
47 try:
38 from pip.download import PipSession
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 if sys.version_info < (2, 7):
68 if sys.version_info < (2, 7):
@@ -63,14 +90,15 b' def _get_requirements(req_filename, excl'
63 parsed = parse_requirements(os.path.join(here, req_filename))
90 parsed = parse_requirements(os.path.join(here, req_filename))
64
91
65 requirements = []
92 requirements = []
66 for ir in parsed:
93 for int_req in parsed:
67 if ir.req and ir.name not in exclude:
94 req_name = get_package_name(int_req)
68 requirements.append(str(ir.req))
95 if req_name not in exclude:
96 requirements.append(req_name)
69 return requirements + extras
97 return requirements + extras
70
98
71
99
72 # requirements extract
100 # requirements extract
73 setup_requirements = ['PasteScript', 'pytest-runner']
101 setup_requirements = ['PasteScript']
74 install_requirements = _get_requirements(
102 install_requirements = _get_requirements(
75 'requirements.txt', exclude=['setuptools', 'entrypoints'])
103 'requirements.txt', exclude=['setuptools', 'entrypoints'])
76 test_requirements = _get_requirements(
104 test_requirements = _get_requirements(
General Comments 0
You need to be logged in to leave comments. Login now