File size: 995 Bytes
3883c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import shlex
import subprocess

from install import ensure_installed
import sys
import autodebug.autodebug as autodebug
from setup_tools import os


def check_python():
    print('Python version: ', sys.version)
    major, minor, patch, variant, _ = sys.version_info
    if major == 3 and minor == 10:
        return
    raise autodebug.WrongPythonVersionException(f'Your python version is not supported. You\'re running "{major}.{minor}.{patch}". But you need "3.10.x"')


def print_git():
    command = 'git log --pretty="Webui version: %H - %cd" -n 1'
    command = command if os.is_windows() else shlex.split(command)
    result = subprocess.run(command, capture_output=True)
    if result.returncode == 0:
        print(result.stdout.decode(encoding=sys.getdefaultencoding()), end='')
    else:
        print('Webui version: Unable to check version, not installed with git.')


def prelaunch_checks():
    check_python()
    print_git()

    ensure_installed()  # Installs missing packages