install_uninstall: prefer shebang with only major version

Having a major.minor version of python in the shebangs, has the unwanted
side effect of requiring an uninstallation and then reinstallation
all the pre-commit hooks, once the system updates the python
installation to a newer minor version, since it will not find the
version which the shebangs specifies.

To make matters worse the uninstallation of the hooks has to be manual
since the script will not be able to run for the aforementioned reason.

This change makes the python symlink with just the major version as the
preferred choice over the major.minor version specified shebang.

Signed-off-by: Antonio Gutierrez <chibby0ne@gmail.com>
This commit is contained in:
Antonio Gutierrez 2020-12-19 04:04:37 +01:00
parent 0ed7930976
commit b64a102e49
No known key found for this signature in database
GPG key ID: 87442126EE4B90AE

View file

@ -58,8 +58,8 @@ def shebang() -> str:
py, _ = os.path.splitext(SYS_EXE) py, _ = os.path.splitext(SYS_EXE)
else: else:
exe_choices = [ exe_choices = [
f'python{sys.version_info[0]}.{sys.version_info[1]}',
f'python{sys.version_info[0]}', f'python{sys.version_info[0]}',
f'python{sys.version_info[0]}.{sys.version_info[1]}',
] ]
# avoid searching for bare `python` as it's likely to be python 2 # avoid searching for bare `python` as it's likely to be python 2
if SYS_EXE != 'python': if SYS_EXE != 'python':