-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathpythoncheck.py
More file actions
43 lines (38 loc) · 1.73 KB
/
pythoncheck.py
File metadata and controls
43 lines (38 loc) · 1.73 KB
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
34
35
36
37
38
39
40
41
42
43
# SPDX-License-Identifier: GPL-3.0-or-later
#
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
# https://github.com/mathoudebine/turing-smart-screen-python/
#
# Copyright (C) 2021 Matthieu Houdebine (mathoudebine)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This file is used to check if Python version used is compatible
import os
import sys
# Oldest / newest version supported
MIN_PYTHON = (3, 9)
MAX_PYTHON = (3, 14)
# For Windows: max Python 3.13 until PythonNet support for 3.14
MAX_PYTHON_WINDOWS = (3, 13)
def check_python_version():
current_version = sys.version_info[:2]
platform = sys.platform
if current_version < MIN_PYTHON or (platform == "win32" and current_version > MAX_PYTHON_WINDOWS) or (
platform != "win32" and current_version > MAX_PYTHON):
print(f"[ERROR] Python {current_version[0]}.{current_version[1]} is not supported by this program. "
f"Python {MIN_PYTHON[0]}.{MIN_PYTHON[1]}-{MAX_PYTHON[0]}.{MAX_PYTHON[1]} required on platform {platform}.")
try:
sys.exit(0)
except:
os._exit(0)