mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Move required python version into pyproject.toml
This commit is contained in:
parent
c373d8c93d
commit
c7250ed3aa
@ -1,3 +1,6 @@
|
||||
[project]
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 160
|
||||
target-version = 'py38'
|
||||
|
24
setup.py
24
setup.py
@ -6,20 +6,28 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, os
|
||||
import sys, os, tomllib, re
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def check_version_info(minver=(3, 8, 0)):
|
||||
vi = sys.version_info
|
||||
if vi < minver:
|
||||
def fmt(v):
|
||||
return '.'.join(map(str, v[:3]))
|
||||
exit('calibre requires Python >= {}. Current Python version: {}'.format(fmt(minver), fmt(vi)))
|
||||
def check_version_info():
|
||||
with open(os.path.join(base, 'pyproject.toml'), 'rb') as f:
|
||||
m = tomllib.load(f)
|
||||
minver = m['project']['requires-python']
|
||||
m = re.match(r'(>=?)(\d+)\.(\d+)', minver)
|
||||
q = int(m.group(2)), int(m.group(3))
|
||||
if m.group(1) == '>=':
|
||||
is_ok = sys.version_info >= q
|
||||
else:
|
||||
is_ok = sys.version_info > q
|
||||
if is_ok:
|
||||
exit(f'calibre requires Python {minver}. Current Python version: {".".join(map(str, sys.version_info[:3]))}')
|
||||
|
||||
|
||||
|
||||
check_version_info()
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, base)
|
||||
|
||||
import setup.commands as commands
|
||||
from setup import prints, get_warnings
|
||||
|
Loading…
x
Reference in New Issue
Block a user