@@ -80,7 +80,6 @@ def __init__(self, args):
8080 self .need_symlink = 0
8181 self .need_sphinx = 0
8282 self .need_pip = 0
83- self .need_virtualenv = 0
8483 self .rec_sphinx_upgrade = 0
8584 self .verbose_warn_install = 1
8685
@@ -919,12 +918,14 @@ def recommend_sphinx_version(self, virtualenv_cmd):
919918 else :
920919 print ("\n Sphinx needs to be installed either:\n 1) via pip/pypi with:\n " )
921920
922- self .python_cmd = os .path .abspath (sys .argv [0 ])
923-
924- print (f"\t { virtualenv_cmd } { self .virtenv_dir } " )
925- print (f"\t . { self .virtenv_dir } /bin/activate" )
926- print (f"\t pip install -r { self .requirement_file } " )
927- self .deactivate_help ()
921+ if not virtualenv_cmd :
922+ print (" Currently not possible.\n " )
923+ print (" Please upgrade Python to a newer version and run this script again" )
924+ else :
925+ print (f"\t { virtualenv_cmd } { self .virtenv_dir } " )
926+ print (f"\t . { self .virtenv_dir } /bin/activate" )
927+ print (f"\t pip install -r { self .requirement_file } " )
928+ self .deactivate_help ()
928929
929930 print ("\n 2) As a package with:" )
930931
@@ -953,6 +954,7 @@ def recommend_sphinx_version(self, virtualenv_cmd):
953954
954955 def check_needs (self ):
955956 self .get_system_release ()
957+ self .python_cmd = sys .executable
956958
957959 # Check if Sphinx is already accessible from current environment
958960 self .check_sphinx ()
@@ -965,56 +967,21 @@ def check_needs(self):
965967 ver = ver_str (self .cur_version )
966968 print (f"Sphinx version: { ver } \n " )
967969
968- # FIXME: Check python command line, trying first python3
969- self .python_cmd = self .which ("python3" )
970- if not self .python_cmd :
971- self .python_cmd = self .check_program ("python" , 0 )
972-
973970 # Check the type of virtual env, depending on Python version
974- if self .python_cmd :
975- if self .virtualenv :
976- try :
977- result = self .run (
978- [self .python_cmd , "--version" ],
979- capture_output = True ,
980- text = True ,
981- check = True ,
982- )
983-
984- output = result .stdout + result .stderr
985-
986- match = re .search (r"(\d+)\.(\d+)\." , output )
987- if match :
988- major = int (match .group (1 ))
989- minor = int (match .group (2 ))
990-
991- if major < 3 :
992- sys .exit ("Python 3 is required to build the kernel docs" )
993- if major == 3 and minor < 3 :
994- self .need_virtualenv = True
995- else :
996- sys .exit (f"Warning: couldn't identify { self .python_cmd } version!" )
997-
998- except subprocess .CalledProcessError as e :
999- sys .exit (f"Error checking Python version: { e } " )
1000- else :
1001- self .add_package ("python-sphinx" , 0 )
971+ virtualenv_cmd = None
1002972
1003- self .venv_ver = self .recommend_sphinx_upgrade ()
973+ if sys .version_info < MIN_PYTHON_VERSION :
974+ min_ver = ver_str (MIN_PYTHON_VERSION )
975+ print (f"ERROR: at least python { min_ver } is required to build the kernel docs" )
976+ self .need_sphinx = 1
1004977
1005- virtualenv_cmd = ""
978+ self . venv_ver = self . recommend_sphinx_upgrade ()
1006979
1007980 if self .need_pip :
1008- # Set virtualenv command line, if python < 3.3
1009- # FIXME: can be removed as we're now with an upper min requirement
1010- # but then we need to check python version
1011- if self .need_virtualenv :
1012- virtualenv_cmd = self .which ("virtualenv-3" )
1013- if not virtualenv_cmd :
1014- virtualenv_cmd = self .which ("virtualenv-3.5" )
1015- if not virtualenv_cmd :
1016- self .check_program ("virtualenv" , 0 )
1017- virtualenv_cmd = "virtualenv"
981+ if sys .version_info < MIN_PYTHON_VERSION :
982+ self .need_pip = False
983+ print ("Warning: python version is not supported." )
984+
1018985 else :
1019986 virtualenv_cmd = f"{ self .python_cmd } -m venv"
1020987 self .check_python_module ("ensurepip" , 0 )
0 commit comments