File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 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:
8181 ],
8282 },
8383 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.
8486 python_requires = ">=3.7" ,
8587)
Original file line number Diff line number Diff line change 1212from typing import Optional , Sequence , Union
1313
1414PIP_SOURCES_ROOT = dirname (dirname (__file__ ))
15+ # Copied from setup.py
16+ PYTHON_REQUIRES = ">=3.7"
1517
1618
1719class PipImportRedirectingFinder :
@@ -30,8 +32,22 @@ def find_spec(
3032 return spec
3133
3234
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+
3348# TODO https://github.com/pypa/pip/issues/11294
3449sys .meta_path .insert (0 , PipImportRedirectingFinder ())
3550
3651assert __name__ == "__main__" , "Cannot run __pip-runner__.py as a non-main module"
52+ check_python_version ()
3753runpy .run_module ("pip" , run_name = "__main__" , alter_sys = True )
You can’t perform that action at this time.
0 commit comments