Merge pull request #170 from makermelissa/master

Add a check for Blinka's minimum required python version
This commit is contained in:
Melissa LeBlanc-Williams 2021-03-16 09:19:09 -07:00 committed by GitHub
commit ef00e56b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import os
shell = Shell() shell = Shell()
shell.group="Blinka" shell.group="Blinka"
default_python = 3 default_python = 3
blinka_minimum_python_version = 3.6
def default_python_version(numeric=True): def default_python_version(numeric=True):
version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True) version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True)
@ -19,6 +20,20 @@ def default_python_version(numeric=True):
return float(version[0:version.rfind(".")]) return float(version[0:version.rfind(".")])
return version return version
def get_python3_version(numeric=True):
version = shell.run_command("python3 -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True)
if numeric:
return float(version[0:version.rfind(".")])
return version
def check_blinka_python_version():
"""
Check the Python 3 version for Blinka (which may be a later version than we're running this script with)
"""
print("Making sure the required version of Python is installed")
if get_python3_version() < blinka_minimum_python_version:
shell.bail("Blinka requires a minimum of Python version {} to install. Please update your OS!".format(blinka_minimum_python_version))
def sys_update(): def sys_update():
print("Updating System Packages") print("Updating System Packages")
if not shell.run_command("sudo apt-get update"): if not shell.run_command("sudo apt-get update"):
@ -85,6 +100,7 @@ Raspberry Pi and installs Blinka
if not shell.prompt("Continue?"): if not shell.prompt("Continue?"):
shell.exit() shell.exit()
sys_update() sys_update()
check_blinka_python_version()
set_raspiconfig() set_raspiconfig()
update_python() update_python()
update_pip() update_pip()