@@ -8,36 +8,27 @@ def pip_import_string(python_exe):
8
8
cmd = [
9
9
python_exe ,
10
10
"-c" ,
11
- "import pip; assert int (pip.__version__.split('.')[0]) <= 9 "
11
+ "import pip; print (pip.__version__) "
12
12
]
13
- p = os_utils .popen (cmd ,stdout = os_utils .pipe , stderr = os_utils .pipe )
14
- p .communicate ()
13
+ p = os_utils .popen (cmd , stdout = os_utils .pipe , stderr = os_utils .pipe )
14
+ stdout , stderr = p .communicate ()
15
+ pip_version = stdout .decode ('utf-8' ).strip ()
16
+ pip_major_version = int (pip_version .split ('.' )[0 ])
17
+ pip_minor_version = int (pip_version .split ('.' )[1 ])
18
+
15
19
# Pip moved its internals to an _internal module in version 10.
16
20
# In order to be compatible with version 9 which has it at at the
17
21
# top level we need to figure out the correct import path here.
18
- if p . returncode == 0 :
22
+ if pip_major_version == 9 :
19
23
return 'from pip import main'
24
+ # Pip changed their import structure again in 19.3
25
+ # https://github.com/pypa/pip/commit/09fd200
26
+ elif pip_major_version >= 19 and pip_minor_version >= 3 :
27
+ return 'from pip._internal.main import main'
20
28
else :
21
29
return 'from pip._internal import main'
22
30
23
31
24
- def pip_runner_string (python_exe ):
25
- os_utils = OSUtils ()
26
- cmd = [
27
- python_exe ,
28
- "-c" ,
29
- "import pip; assert (int(pip.__version__.split('.')[0]) <= 19 and int(pip.__version__.split('.')[1]) < 3)"
30
- ]
31
- p = os_utils .popen (cmd , stdout = os_utils .pipe , stderr = os_utils .pipe )
32
- p .communicate ()
33
- # Pip changed main to be a module instead of a function from 19.3
34
- # and added a separate main function within the main module.
35
- if p .returncode == 0 :
36
- return 'import sys; %s; sys.exit(main(%s))'
37
- else :
38
- return 'import sys; %s; sys.exit(main.main(%s))'
39
-
40
-
41
32
if os .name == 'nt' :
42
33
# windows
43
34
# This is the actual patch used on windows to prevent distutils from
0 commit comments