|
21 | 21 |
|
22 | 22 | from distutils.version import StrictVersion
|
23 | 23 |
|
24 |
| -GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' |
25 |
| - |
26 |
| -try: |
27 |
| - import pip |
28 |
| - from pip import __version__ as pip_version |
29 |
| -except ImportError as e: |
30 |
| - print('Failed to import pip: %s' % (str(e))) |
31 |
| - print('') |
32 |
| - print('Download pip:\n%s' % (GET_PIP)) |
33 |
| - sys.exit(1) |
34 |
| - |
35 |
| -try: |
36 |
| - # pip < 10.0 |
37 |
| - from pip.req import parse_requirements |
38 |
| -except ImportError: |
39 |
| - # pip >= 10.0 |
40 |
| - |
41 |
| - try: |
42 |
| - from pip._internal.req.req_file import parse_requirements |
43 |
| - except ImportError as e: |
44 |
| - print('Failed to import parse_requirements from pip: %s' % (str(e))) |
45 |
| - print('Using pip: %s' % (str(pip_version))) |
46 |
| - sys.exit(1) |
47 |
| - |
48 | 24 | __all__ = [
|
49 |
| - 'check_pip_version', |
50 |
| - 'fetch_requirements', |
51 | 25 | 'apply_vagrant_workaround',
|
52 | 26 | 'get_version_string',
|
53 | 27 | 'parse_version_string'
|
54 | 28 | ]
|
55 | 29 |
|
56 | 30 |
|
57 |
| -def check_pip_version(min_version='6.0.0'): |
58 |
| - """ |
59 |
| - Ensure that a minimum supported version of pip is installed. |
60 |
| - """ |
61 |
| - if StrictVersion(pip.__version__) < StrictVersion(min_version): |
62 |
| - print("Upgrade pip, your version '{0}' " |
63 |
| - "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, |
64 |
| - min_version, |
65 |
| - GET_PIP)) |
66 |
| - sys.exit(1) |
67 |
| - |
68 |
| - |
69 |
| -def fetch_requirements(requirements_file_path): |
70 |
| - """ |
71 |
| - Return a list of requirements and links by parsing the provided requirements file. |
72 |
| - """ |
73 |
| - links = [] |
74 |
| - reqs = [] |
75 |
| - for req in parse_requirements(requirements_file_path, session=False): |
76 |
| - # Note: req.url was used before 9.0.0 and req.link is used in all the recent versions |
77 |
| - link = getattr(req, 'link', getattr(req, 'url', None)) |
78 |
| - if link: |
79 |
| - links.append(str(link)) |
80 |
| - reqs.append(str(req.req)) |
81 |
| - return (reqs, links) |
82 |
| - |
83 |
| - |
84 | 31 | def apply_vagrant_workaround():
|
85 | 32 | """
|
86 | 33 | Function which detects if the script is being executed inside vagrant and if it is, it deletes
|
|
0 commit comments