From f08f0f9dbdc614a66f22f7cfcbef7a43db22d1b5 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 15 Oct 2018 17:17:03 +0200 Subject: [PATCH 1/3] Filter tic output to remove "older tic versions may treat the description field as an alias" --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 670327e09..cb873c03c 100755 --- a/setup.py +++ b/setup.py @@ -599,7 +599,11 @@ def package(args, for_bundle=False, sh_launcher=False): for x in (libdir, os.path.join(ddir, 'share')): odir = os.path.join(x, 'terminfo') safe_makedirs(odir) - subprocess.check_call(['tic', '-x', '-o' + odir, 'terminfo/kitty.terminfo']) + proc = subprocess.run(['tic', '-x', '-o' + odir, 'terminfo/kitty.terminfo'], check=True, text=True, stderr=subprocess.PIPE) + regex = '^"terminfo/kitty.terminfo", line [0-9]+, col [0-9]+, terminal \'xterm-kitty\': older tic versions may treat the description field as an alias$' + err_msg = proc.stderr.rstrip() + if not re.match(regex, err_msg): + print(err_msg, file=sys.stderr) if not glob.glob(os.path.join(odir, '*/xterm-kitty')): raise SystemExit('tic failed to output the compiled kitty terminfo file') shutil.copy2('__main__.py', libdir) From a045ac3bd7ad5fe5ab1dd2d0f609c6f744bc24c1 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 18 Oct 2018 12:15:37 +0200 Subject: [PATCH 2/3] Decode tic stderr using utf-8 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index cb873c03c..5e9ee5e79 100755 --- a/setup.py +++ b/setup.py @@ -599,9 +599,9 @@ def package(args, for_bundle=False, sh_launcher=False): for x in (libdir, os.path.join(ddir, 'share')): odir = os.path.join(x, 'terminfo') safe_makedirs(odir) - proc = subprocess.run(['tic', '-x', '-o' + odir, 'terminfo/kitty.terminfo'], check=True, text=True, stderr=subprocess.PIPE) + proc = subprocess.run(['tic', '-x', '-o' + odir, 'terminfo/kitty.terminfo'], check=True, stderr=subprocess.PIPE) regex = '^"terminfo/kitty.terminfo", line [0-9]+, col [0-9]+, terminal \'xterm-kitty\': older tic versions may treat the description field as an alias$' - err_msg = proc.stderr.rstrip() + err_msg = proc.stderr.decode('utf-8').rstrip() if not re.match(regex, err_msg): print(err_msg, file=sys.stderr) if not glob.glob(os.path.join(odir, '*/xterm-kitty')): From 88aab20376abb33c7bcc5dc20f7b4d812b20077d Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 18 Oct 2018 12:20:22 +0200 Subject: [PATCH 3/3] Loop through lines of tic output to correctly handle multiple lines --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 5e9ee5e79..eb077c4f4 100755 --- a/setup.py +++ b/setup.py @@ -601,9 +601,9 @@ def package(args, for_bundle=False, sh_launcher=False): safe_makedirs(odir) proc = subprocess.run(['tic', '-x', '-o' + odir, 'terminfo/kitty.terminfo'], check=True, stderr=subprocess.PIPE) regex = '^"terminfo/kitty.terminfo", line [0-9]+, col [0-9]+, terminal \'xterm-kitty\': older tic versions may treat the description field as an alias$' - err_msg = proc.stderr.decode('utf-8').rstrip() - if not re.match(regex, err_msg): - print(err_msg, file=sys.stderr) + for error in proc.stderr.decode('utf-8').splitlines(): + if not re.match(regex, error): + print(error, file=sys.stderr) if not glob.glob(os.path.join(odir, '*/xterm-kitty')): raise SystemExit('tic failed to output the compiled kitty terminfo file') shutil.copy2('__main__.py', libdir)