Up to Python 3.2, the virtual environment were created via virtualenv binary. As we dropped support for such old version, clean up the code.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -80,7 +80,6 @@ class SphinxDependencyChecker: · 79 unmodified lines | ||
| 80 | 80 | self.need_symlink = 0 |
| 81 | 81 | self.need_sphinx = 0 |
| 82 | 82 | self.need_pip = 0 |
| 83 | − self.need_virtualenv = 0 | |
| 84 | 83 | self.rec_sphinx_upgrade = 0 |
| 85 | 84 | self.verbose_warn_install = 1 |
| 86 | 85 | |
| @@ -919,12 +918,14 @@ class SphinxDependencyChecker: · 832 unmodified lines | ||
| 919 | 918 | else: |
| 920 | 919 | print("\nSphinx needs to be installed either:\n1) via pip/pypi with:\n") |
| 921 | 920 | |
| 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"\tpip 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"\tpip install -r {self.requirement_file}") | |
| 928 | + self.deactivate_help() | |
| 928 | 929 | |
| 929 | 930 | print("\n2) As a package with:") |
| 930 | 931 | |
| @@ -953,6 +954,7 @@ class SphinxDependencyChecker: · 22 unmodified lines | ||
| 953 | 954 | |
| 954 | 955 | def check_needs(self): |
| 955 | 956 | self.get_system_release() |
| 957 | + self.python_cmd = sys.executable | |
| 956 | 958 | |
| 957 | 959 | # Check if Sphinx is already accessible from current environment |
| 958 | 960 | self.check_sphinx() |
| @@ -965,56 +967,21 @@ class SphinxDependencyChecker: · 6 unmodified lines | ||
| 965 | 967 | ver = ver_str(self.cur_version) |
| 966 | 968 | print(f"Sphinx version: {ver}\n") |
| 967 | 969 | |
| 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 | − | |
| 973 | 970 | # 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 | |
| 1002 | 972 | |
| 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 | |
| 1004 | 977 | |
| 1005 | − virtualenv_cmd = "" | |
| 978 | + self.venv_ver = self.recommend_sphinx_upgrade() | |
| 1006 | 979 | |
| 1007 | 980 | 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 | + | |
| 1018 | 985 | else: |
| 1019 | 986 | virtualenv_cmd = f"{self.python_cmd} -m venv" |
| 1020 | 987 | self.check_python_module("ensurepip", 0) |