Use requires-python in pyproject.toml to specify python requirement
This commit is contained in:
parent
4fe65f75bc
commit
c72963dfc5
2 changed files with 20 additions and 3 deletions
|
|
@ -1,3 +1,6 @@
|
|||
[project]
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[tool.mypy]
|
||||
files = 'kitty,kittens,glfw,*.py,docs/conf.py,gen'
|
||||
no_implicit_optional = true
|
||||
|
|
@ -23,7 +26,6 @@ report_progress = true
|
|||
|
||||
[tool.ruff]
|
||||
line-length = 160
|
||||
target-version = 'py38'
|
||||
select = ['E', 'F', 'I', 'RUF100']
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
|
|
|
|||
19
setup.py
19
setup.py
|
|
@ -25,10 +25,25 @@
|
|||
from glfw import glfw
|
||||
from glfw.glfw import ISA, BinaryArch, Command, CompileKey, CompilerType
|
||||
|
||||
if sys.version_info[:2] < (3, 8):
|
||||
raise SystemExit('kitty requires python >= 3.8')
|
||||
src_base = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def check_version_info() -> None:
|
||||
import tomllib
|
||||
with open(os.path.join(src_base, 'pyproject.toml'), 'rb') as f:
|
||||
m = tomllib.load(f)
|
||||
minver = m['project']['requires-python']
|
||||
match = re.match(r'(>=?)(\d+)\.(\d+)', minver)
|
||||
assert match is not None
|
||||
q = int(match.group(2)), int(match.group(3))
|
||||
if match.group(1) == '>=':
|
||||
is_ok = sys.version_info >= q
|
||||
else:
|
||||
is_ok = sys.version_info > q
|
||||
if not is_ok:
|
||||
exit(f'calibre requires Python {minver}. Current Python version: {".".join(map(str, sys.version_info[:3]))}')
|
||||
|
||||
|
||||
check_version_info()
|
||||
verbose = False
|
||||
build_dir = 'build'
|
||||
constants = os.path.join('kitty', 'constants.py')
|
||||
|
|
|
|||
Loading…
Reference in a new issue