File tree 2 files changed +18
-0
lines changed 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -81,5 +81,7 @@ def get_version(rel_path: str) -> str:
81
81
],
82
82
},
83
83
zip_safe = False ,
84
+ # NOTE: python_requires is duplicated in __pip-runner__.py.
85
+ # When changing this value, please change the other copy as well.
84
86
python_requires = ">=3.7" ,
85
87
)
Original file line number Diff line number Diff line change 12
12
from typing import Optional , Sequence , Union
13
13
14
14
PIP_SOURCES_ROOT = dirname (dirname (__file__ ))
15
+ # Copied from setup.py
16
+ PYTHON_REQUIRES = ">=3.7"
15
17
16
18
17
19
class PipImportRedirectingFinder :
@@ -30,8 +32,22 @@ def find_spec(
30
32
return spec
31
33
32
34
35
+ def check_python_version ():
36
+ # Import here to ensure the imports happen after the sys.meta_path change.
37
+ from pip ._vendor .packaging .version import Version
38
+ from pip ._vendor .packaging .specifiers import SpecifierSet
39
+
40
+ py_ver = Version ("{0.major}.{0.minor}.{0.micro}" .format (sys .version_info ))
41
+ if py_ver not in SpecifierSet (PYTHON_REQUIRES ):
42
+ raise SystemExit (
43
+ f"This version of pip does not support python { py_ver } "
44
+ f"(requires { PYTHON_REQUIRES } )"
45
+ )
46
+
47
+
33
48
# TODO https://github.com/pypa/pip/issues/11294
34
49
sys .meta_path .insert (0 , PipImportRedirectingFinder ())
35
50
36
51
assert __name__ == "__main__" , "Cannot run __pip-runner__.py as a non-main module"
52
+ check_python_version ()
37
53
runpy .run_module ("pip" , run_name = "__main__" , alter_sys = True )
You can’t perform that action at this time.
0 commit comments