11#!/usr/bin/env python3
2- # vim:fileencoding=utf-8
32# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
43
54import argparse
2726from glfw import glfw
2827from glfw .glfw import Command , CompileKey
2928
30- if sys .version_info [:2 ] < (3 , 6 ):
31- raise SystemExit ('kitty requires python >= 3.6 ' )
29+ if sys .version_info [:2 ] < (3 , 7 ):
30+ raise SystemExit ('kitty requires python >= 3.7 ' )
3231base = os .path .dirname (os .path .abspath (__file__ ))
3332sys .path .insert (0 , base )
3433del sys .path [0 ]
@@ -104,7 +103,7 @@ def pkg_config(pkg: str, *args: str) -> List[str]:
104103 )
105104 )
106105 except subprocess .CalledProcessError :
107- raise SystemExit ('The package {} was not found on your system' . format ( error ( pkg )) )
106+ raise SystemExit (f 'The package { error ( pkg ) } was not found on your system' )
108107
109108
110109def pkg_version (package : str ) -> Tuple [int , int ]:
@@ -118,7 +117,7 @@ def pkg_version(package: str) -> Tuple[int, int]:
118117
119118
120119def at_least_version (package : str , major : int , minor : int = 0 ) -> None :
121- q = '{ }.{}' . format ( major , minor )
120+ q = f' { major } .{ minor } '
122121 if subprocess .run ([PKGCONFIG , package , '--atleast-version=' + q ]
123122 ).returncode != 0 :
124123 qmajor = qminor = 0
@@ -185,10 +184,10 @@ def get_python_flags(cflags: List[str]) -> List[str]:
185184 if fw :
186185 for var in 'data include stdlib' .split ():
187186 val = sysconfig .get_path (var )
188- if val and '/{}.framework' . format ( fw ) in val :
189- fdir = val [:val .index ('/{}.framework' . format ( fw ) )]
187+ if val and f '/{ fw } .framework' in val :
188+ fdir = val [:val .index (f '/{ fw } .framework' )]
190189 if os .path .isdir (
191- os .path .join (fdir , '{ }.framework'. format ( fw ) )
190+ os .path .join (fdir , f' { fw } .framework' )
192191 ):
193192 framework_dir = fdir
194193 break
@@ -406,8 +405,8 @@ def kitty_env() -> Env:
406405 # We add 4000 to the primary version because vim turns on SGR mouse mode
407406 # automatically if this version is high enough
408407 cppflags = ans .cppflags
409- cppflags .append ('-DPRIMARY_VERSION={}' . format ( version [0 ] + 4000 ) )
410- cppflags .append ('-DSECONDARY_VERSION={}' . format ( version [1 ]) )
408+ cppflags .append (f '-DPRIMARY_VERSION={ version [0 ] + 4000 } ' )
409+ cppflags .append (f '-DSECONDARY_VERSION={ version [1 ]} ' )
411410 cppflags .append ('-DXT_VERSION="{}"' .format ('.' .join (map (str , version ))))
412411 at_least_version ('harfbuzz' , 1 , 5 )
413412 cflags .extend (pkg_config ('libpng' , '--cflags-only-I' ))
@@ -484,7 +483,7 @@ def get_vcs_rev_defines(env: Env, src: str) -> List[str]:
484483 with open (os .path .join (gitloc , 'refs/heads/master' )) as f :
485484 rev = f .read ()
486485
487- ans .append ('KITTY_VCS_REV="{}"' . format ( rev .strip ()) )
486+ ans .append (f 'KITTY_VCS_REV="{ rev .strip ()} "' )
488487 return ans
489488
490489
@@ -573,9 +572,9 @@ def wait() -> None:
573572 if verbose :
574573 print (' ' .join (compile_cmd .cmd ))
575574 elif isatty :
576- print ('\r \x1b [K[{}/{}] {}' . format ( num , total , compile_cmd .desc ) , end = '' )
575+ print (f '\r \x1b [K[{ num } /{ total } ] { compile_cmd .desc } ' , end = '' )
577576 else :
578- print ('[{}/{}] {}' . format ( num , total , compile_cmd .desc ) , flush = True )
577+ print (f '[{ num } /{ total } ] { compile_cmd .desc } ' , flush = True )
579578 printed = True
580579 w = subprocess .Popen (compile_cmd .cmd , stdout = subprocess .DEVNULL , stderr = subprocess .STDOUT )
581580 workers [w .pid ] = compile_cmd , w
@@ -696,12 +695,12 @@ def compile_c_extension(
696695 cmd = kenv .cc + ['-MMD' ] + cppflags + kenv .cflags
697696 cmd += ['-c' , src ] + ['-o' , dest ]
698697 key = CompileKey (original_src , os .path .basename (dest ))
699- desc = 'Compiling {} ...' . format ( emphasis (desc_prefix + src ))
698+ desc = f 'Compiling { emphasis (desc_prefix + src )} ...'
700699 compilation_database .add_command (desc , cmd , partial (newer , dest , * dependecies_for (src , dest , headers )), key = key , keyfile = src )
701700 dest = os .path .join (build_dir , module + '.so' )
702701 real_dest = module + '.so'
703702 os .makedirs (os .path .dirname (dest ), exist_ok = True )
704- desc = 'Linking {} ...' . format ( emphasis (desc_prefix + module ))
703+ desc = f 'Linking { emphasis (desc_prefix + module )} ...'
705704 # Old versions of clang don't like -pthread being passed to the linker
706705 # Don't treat linker warnings as errors (linker generates spurious
707706 # warnings on some old systems)
@@ -755,7 +754,7 @@ def compile_glfw(compilation_database: CompilationDatabase) -> None:
755754 continue
756755 compile_c_extension (
757756 genv , 'kitty/glfw-' + module , compilation_database ,
758- sources , all_headers , desc_prefix = '[{}] ' . format ( module ) )
757+ sources , all_headers , desc_prefix = f '[{ module } ] ' )
759758
760759
761760def kittens_env () -> Env :
@@ -784,7 +783,7 @@ def files(
784783 ) -> Tuple [str , List [str ], List [str ], str , Sequence [str ], Sequence [str ]]:
785784 sources = list (filter (filter_sources , list (extra_sources ) + list_files (os .path .join ('kittens' , kitten , '*.c' ))))
786785 headers = list_files (os .path .join ('kittens' , kitten , '*.h' )) + list (extra_headers )
787- return kitten , sources , headers , 'kittens/{}/{}' . format ( kitten , output ) , includes , libraries
786+ return kitten , sources , headers , f 'kittens/{ kitten } /{ output } ' , includes , libraries
788787
789788 for kitten , sources , all_headers , dest , includes , libraries in (
790789 files ('unicode_input' , 'unicode_names' ),
@@ -848,8 +847,8 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
848847 cflags .append ('-O3' )
849848 if bundle_type .endswith ('-freeze' ):
850849 cppflags .append ('-DFOR_BUNDLE' )
851- cppflags .append ('-DPYVER="{}"' . format ( sysconfig .get_python_version ()) )
852- cppflags .append ('-DKITTY_LIB_DIR_NAME="{}"' . format ( args .libdir_name ) )
850+ cppflags .append (f '-DPYVER="{ sysconfig .get_python_version ()} "' )
851+ cppflags .append (f '-DKITTY_LIB_DIR_NAME="{ args .libdir_name } "' )
853852 elif bundle_type == 'source' :
854853 cppflags .append ('-DFROM_SOURCE' )
855854 if bundle_type .startswith ('macos-' ):
@@ -859,8 +858,8 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
859858 elif bundle_type == 'source' :
860859 klp = os .path .relpath ('.' , launcher_dir )
861860 else :
862- raise SystemExit ('Unknown bundle type: {}' . format ( bundle_type ) )
863- cppflags .append ('-DKITTY_LIB_PATH="{}"' . format ( klp ) )
861+ raise SystemExit (f 'Unknown bundle type: { bundle_type } ' )
862+ cppflags .append (f '-DKITTY_LIB_PATH="{ klp } "' )
864863 pylib = get_python_flags (cflags )
865864 cppflags += shlex .split (os .environ .get ('CPPFLAGS' , '' ))
866865 cflags += shlex .split (os .environ .get ('CFLAGS' , '' ))
0 commit comments