Drop support for python 3.6
It is being EOLed next month (https://www.python.org/dev/peps/pep-0494/) which is when I expect the next kitty release as well
This commit is contained in:
parent
bfdb09d29f
commit
f0e8ab8f31
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -20,15 +20,15 @@ jobs:
|
||||
cc: [gcc, clang]
|
||||
include:
|
||||
- python: a
|
||||
pyver: 3.6
|
||||
pyver: 3.7
|
||||
sanitize: 0
|
||||
|
||||
- python: b
|
||||
pyver: 3.7
|
||||
pyver: 3.8
|
||||
sanitize: 1
|
||||
|
||||
- python: c
|
||||
pyver: 3.8
|
||||
pyver: 3.9
|
||||
sanitize: 1
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import subprocess
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import string
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
@ -255,7 +254,7 @@ def write_case(spec: Union[Tuple[int, ...], int], p: Callable[..., None]) -> Non
|
||||
if isinstance(spec, tuple):
|
||||
p('\t\tcase 0x{:x} ... 0x{:x}:'.format(*spec))
|
||||
else:
|
||||
p('\t\tcase 0x{:x}:'.format(spec))
|
||||
p(f'\t\tcase 0x{spec:x}:')
|
||||
|
||||
|
||||
@contextmanager
|
||||
@ -353,10 +352,10 @@ def classes_to_regex(classes: Iterable[str], exclude: str = '') -> Iterable[str]
|
||||
|
||||
def as_string(codepoint: int) -> str:
|
||||
if codepoint < 256:
|
||||
return r'\x{:02x}'.format(codepoint)
|
||||
return fr'\x{codepoint:02x}'
|
||||
if codepoint <= 0xffff:
|
||||
return r'\u{:04x}'.format(codepoint)
|
||||
return r'\U{:08x}'.format(codepoint)
|
||||
return fr'\u{codepoint:04x}'
|
||||
return fr'\U{codepoint:08x}'
|
||||
|
||||
for spec in get_ranges(list(chars)):
|
||||
if isinstance(spec, tuple):
|
||||
|
||||
@ -181,24 +181,12 @@ def resolve_custom_file(path: str) -> str:
|
||||
|
||||
|
||||
def list_kitty_resources(package: str = 'kitty') -> Iterable[str]:
|
||||
if sys.version_info < (3, 7):
|
||||
from importlib_resources import files
|
||||
|
||||
def contents(package: str) -> Iterable[str]:
|
||||
return (path.name for path in files(package).iterdir())
|
||||
else:
|
||||
from importlib.resources import contents
|
||||
from importlib.resources import contents
|
||||
return contents(package)
|
||||
|
||||
|
||||
def read_kitty_resource(name: str, package_name: str = 'kitty') -> bytes:
|
||||
if sys.version_info < (3, 7):
|
||||
from importlib_resources import files
|
||||
|
||||
def read_binary(package: str, resource: str) -> bytes:
|
||||
return (files(package) / resource).read_bytes()
|
||||
else:
|
||||
from importlib.resources import read_binary
|
||||
from importlib.resources import read_binary
|
||||
|
||||
return read_binary(package_name, name)
|
||||
|
||||
|
||||
@ -5,16 +5,10 @@ import importlib
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set, Iterable
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set
|
||||
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
from importlib_resources import files
|
||||
|
||||
def contents(package: str) -> Iterable[str]:
|
||||
return (path.name for path in files(package).iterdir())
|
||||
else:
|
||||
from importlib.resources import contents
|
||||
from importlib.resources import contents
|
||||
|
||||
|
||||
def itertests(suite: unittest.TestSuite) -> Generator[unittest.TestCase, None, None]:
|
||||
|
||||
19
publish.py
19
publish.py
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import argparse
|
||||
@ -28,7 +27,7 @@ with open('kitty/constants.py') as f:
|
||||
raw = f.read()
|
||||
nv = re.search(r'^version: Version\s+=\s+Version\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE)
|
||||
if nv is not None:
|
||||
version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3))
|
||||
version = f'{nv.group(1)}.{nv.group(2)}.{nv.group(3)}'
|
||||
ap = re.search(r"^appname: str\s+=\s+'([^']+)'", raw, flags=re.MULTILINE)
|
||||
if ap is not None:
|
||||
appname = ap.group(1)
|
||||
@ -68,7 +67,7 @@ def run_build(args: Any) -> None:
|
||||
def run_tag(args: Any) -> None:
|
||||
call('git push')
|
||||
call('git tag -s v{0} -m version-{0}'.format(version))
|
||||
call('git push origin v{0}'.format(version))
|
||||
call(f'git push origin v{version}')
|
||||
|
||||
|
||||
def run_man(args: Any) -> None:
|
||||
@ -197,7 +196,7 @@ class ReadFileWithProgressReporting(io.FileIO): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class Base(object): # {{{
|
||||
class Base: # {{{
|
||||
|
||||
def info(self, *args: Any, **kwargs: Any) -> None:
|
||||
print(*args, **kwargs)
|
||||
@ -293,7 +292,7 @@ class GitHub(Base): # {{{
|
||||
release['tag_name'])
|
||||
for asset in release['assets']:
|
||||
r = self.requests.delete(
|
||||
self.API + 'repos/%s/%s/releases/assets/%s' % (
|
||||
self.API + 'repos/{}/{}/releases/assets/{}'.format(
|
||||
self.username, self.reponame, asset['id']))
|
||||
if r.status_code != 204:
|
||||
self.fail(
|
||||
@ -303,7 +302,7 @@ class GitHub(Base): # {{{
|
||||
|
||||
def do_upload(self, url: str, path: str, desc: str, fname: str) -> requests.Response:
|
||||
mime_type = mimetypes.guess_type(fname)[0] or 'application/octet-stream'
|
||||
self.info('Uploading to GitHub: %s (%s)' % (fname, mime_type))
|
||||
self.info(f'Uploading to GitHub: {fname} ({mime_type})')
|
||||
with ReadFileWithProgressReporting(path) as f:
|
||||
return self.requests.post(
|
||||
url,
|
||||
@ -325,7 +324,7 @@ class GitHub(Base): # {{{
|
||||
return bool(error_code == 'already_exists')
|
||||
|
||||
def existing_assets(self, release_id: str) -> Dict[str, str]:
|
||||
url = self.API + 'repos/%s/%s/releases/%s/assets' % (
|
||||
url = self.API + 'repos/{}/{}/releases/{}/assets'.format(
|
||||
self.username, self.reponame, release_id)
|
||||
r = self.requests.get(url)
|
||||
if r.status_code != 200:
|
||||
@ -341,7 +340,7 @@ class GitHub(Base): # {{{
|
||||
return dict(r.json())
|
||||
if self.is_nightly:
|
||||
raise SystemExit('No existing nightly release found on GitHub')
|
||||
url = self.API + 'repos/%s/%s/releases' % (self.username, self.reponame)
|
||||
url = self.API + f'repos/{self.username}/{self.reponame}/releases'
|
||||
r = self.requests.post(
|
||||
url,
|
||||
data=json.dumps({
|
||||
@ -413,7 +412,7 @@ def current_branch() -> str:
|
||||
|
||||
def require_git_master(branch: str = 'master') -> None:
|
||||
if current_branch() != branch:
|
||||
raise SystemExit('You must be in the {} git branch'.format(branch))
|
||||
raise SystemExit(f'You must be in the {branch} git branch')
|
||||
|
||||
|
||||
def safe_read(path: str) -> str:
|
||||
@ -490,7 +489,7 @@ def main() -> None:
|
||||
del actions[1:]
|
||||
else:
|
||||
try:
|
||||
ans = input('Publish version \033[91m{}\033[m (y/n): '.format(version))
|
||||
ans = input(f'Publish version \033[91m{version}\033[m (y/n): ')
|
||||
except KeyboardInterrupt:
|
||||
ans = 'n'
|
||||
if ans.lower() != 'y':
|
||||
|
||||
41
setup.py
41
setup.py
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import argparse
|
||||
@ -27,8 +26,8 @@ from typing import (
|
||||
from glfw import glfw
|
||||
from glfw.glfw import Command, CompileKey
|
||||
|
||||
if sys.version_info[:2] < (3, 6):
|
||||
raise SystemExit('kitty requires python >= 3.6')
|
||||
if sys.version_info[:2] < (3, 7):
|
||||
raise SystemExit('kitty requires python >= 3.7')
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, base)
|
||||
del sys.path[0]
|
||||
@ -104,7 +103,7 @@ def pkg_config(pkg: str, *args: str) -> List[str]:
|
||||
)
|
||||
)
|
||||
except subprocess.CalledProcessError:
|
||||
raise SystemExit('The package {} was not found on your system'.format(error(pkg)))
|
||||
raise SystemExit(f'The package {error(pkg)} was not found on your system')
|
||||
|
||||
|
||||
def pkg_version(package: str) -> Tuple[int, int]:
|
||||
@ -118,7 +117,7 @@ def pkg_version(package: str) -> Tuple[int, int]:
|
||||
|
||||
|
||||
def at_least_version(package: str, major: int, minor: int = 0) -> None:
|
||||
q = '{}.{}'.format(major, minor)
|
||||
q = f'{major}.{minor}'
|
||||
if subprocess.run([PKGCONFIG, package, '--atleast-version=' + q]
|
||||
).returncode != 0:
|
||||
qmajor = qminor = 0
|
||||
@ -185,10 +184,10 @@ def get_python_flags(cflags: List[str]) -> List[str]:
|
||||
if fw:
|
||||
for var in 'data include stdlib'.split():
|
||||
val = sysconfig.get_path(var)
|
||||
if val and '/{}.framework'.format(fw) in val:
|
||||
fdir = val[:val.index('/{}.framework'.format(fw))]
|
||||
if val and f'/{fw}.framework' in val:
|
||||
fdir = val[:val.index(f'/{fw}.framework')]
|
||||
if os.path.isdir(
|
||||
os.path.join(fdir, '{}.framework'.format(fw))
|
||||
os.path.join(fdir, f'{fw}.framework')
|
||||
):
|
||||
framework_dir = fdir
|
||||
break
|
||||
@ -406,8 +405,8 @@ def kitty_env() -> Env:
|
||||
# We add 4000 to the primary version because vim turns on SGR mouse mode
|
||||
# automatically if this version is high enough
|
||||
cppflags = ans.cppflags
|
||||
cppflags.append('-DPRIMARY_VERSION={}'.format(version[0] + 4000))
|
||||
cppflags.append('-DSECONDARY_VERSION={}'.format(version[1]))
|
||||
cppflags.append(f'-DPRIMARY_VERSION={version[0] + 4000}')
|
||||
cppflags.append(f'-DSECONDARY_VERSION={version[1]}')
|
||||
cppflags.append('-DXT_VERSION="{}"'.format('.'.join(map(str, version))))
|
||||
at_least_version('harfbuzz', 1, 5)
|
||||
cflags.extend(pkg_config('libpng', '--cflags-only-I'))
|
||||
@ -484,7 +483,7 @@ def get_vcs_rev_defines(env: Env, src: str) -> List[str]:
|
||||
with open(os.path.join(gitloc, 'refs/heads/master')) as f:
|
||||
rev = f.read()
|
||||
|
||||
ans.append('KITTY_VCS_REV="{}"'.format(rev.strip()))
|
||||
ans.append(f'KITTY_VCS_REV="{rev.strip()}"')
|
||||
return ans
|
||||
|
||||
|
||||
@ -573,9 +572,9 @@ def parallel_run(items: List[Command]) -> None:
|
||||
if verbose:
|
||||
print(' '.join(compile_cmd.cmd))
|
||||
elif isatty:
|
||||
print('\r\x1b[K[{}/{}] {}'.format(num, total, compile_cmd.desc), end='')
|
||||
print(f'\r\x1b[K[{num}/{total}] {compile_cmd.desc}', end='')
|
||||
else:
|
||||
print('[{}/{}] {}'.format(num, total, compile_cmd.desc), flush=True)
|
||||
print(f'[{num}/{total}] {compile_cmd.desc}', flush=True)
|
||||
printed = True
|
||||
w = subprocess.Popen(compile_cmd.cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
workers[w.pid] = compile_cmd, w
|
||||
@ -696,12 +695,12 @@ def compile_c_extension(
|
||||
cmd = kenv.cc + ['-MMD'] + cppflags + kenv.cflags
|
||||
cmd += ['-c', src] + ['-o', dest]
|
||||
key = CompileKey(original_src, os.path.basename(dest))
|
||||
desc = 'Compiling {} ...'.format(emphasis(desc_prefix + src))
|
||||
desc = f'Compiling {emphasis(desc_prefix + src)} ...'
|
||||
compilation_database.add_command(desc, cmd, partial(newer, dest, *dependecies_for(src, dest, headers)), key=key, keyfile=src)
|
||||
dest = os.path.join(build_dir, module + '.so')
|
||||
real_dest = module + '.so'
|
||||
os.makedirs(os.path.dirname(dest), exist_ok=True)
|
||||
desc = 'Linking {} ...'.format(emphasis(desc_prefix + module))
|
||||
desc = f'Linking {emphasis(desc_prefix + module)} ...'
|
||||
# Old versions of clang don't like -pthread being passed to the linker
|
||||
# Don't treat linker warnings as errors (linker generates spurious
|
||||
# warnings on some old systems)
|
||||
@ -755,7 +754,7 @@ def compile_glfw(compilation_database: CompilationDatabase) -> None:
|
||||
continue
|
||||
compile_c_extension(
|
||||
genv, 'kitty/glfw-' + module, compilation_database,
|
||||
sources, all_headers, desc_prefix='[{}] '.format(module))
|
||||
sources, all_headers, desc_prefix=f'[{module}] ')
|
||||
|
||||
|
||||
def kittens_env() -> Env:
|
||||
@ -784,7 +783,7 @@ def compile_kittens(compilation_database: CompilationDatabase) -> None:
|
||||
) -> Tuple[str, List[str], List[str], str, Sequence[str], Sequence[str]]:
|
||||
sources = list(filter(filter_sources, list(extra_sources) + list_files(os.path.join('kittens', kitten, '*.c'))))
|
||||
headers = list_files(os.path.join('kittens', kitten, '*.h')) + list(extra_headers)
|
||||
return kitten, sources, headers, 'kittens/{}/{}'.format(kitten, output), includes, libraries
|
||||
return kitten, sources, headers, f'kittens/{kitten}/{output}', includes, libraries
|
||||
|
||||
for kitten, sources, all_headers, dest, includes, libraries in (
|
||||
files('unicode_input', 'unicode_names'),
|
||||
@ -848,8 +847,8 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
|
||||
cflags.append('-O3')
|
||||
if bundle_type.endswith('-freeze'):
|
||||
cppflags.append('-DFOR_BUNDLE')
|
||||
cppflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
|
||||
cppflags.append('-DKITTY_LIB_DIR_NAME="{}"'.format(args.libdir_name))
|
||||
cppflags.append(f'-DPYVER="{sysconfig.get_python_version()}"')
|
||||
cppflags.append(f'-DKITTY_LIB_DIR_NAME="{args.libdir_name}"')
|
||||
elif bundle_type == 'source':
|
||||
cppflags.append('-DFROM_SOURCE')
|
||||
if bundle_type.startswith('macos-'):
|
||||
@ -859,8 +858,8 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
|
||||
elif bundle_type == 'source':
|
||||
klp = os.path.relpath('.', launcher_dir)
|
||||
else:
|
||||
raise SystemExit('Unknown bundle type: {}'.format(bundle_type))
|
||||
cppflags.append('-DKITTY_LIB_PATH="{}"'.format(klp))
|
||||
raise SystemExit(f'Unknown bundle type: {bundle_type}')
|
||||
cppflags.append(f'-DKITTY_LIB_PATH="{klp}"')
|
||||
pylib = get_python_flags(cflags)
|
||||
cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
|
||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user