Fix #1435
This commit is contained in:
parent
fc9ffb3115
commit
13254ac4d5
@ -1,18 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(base)
|
||||
sys.path.insert(0, base)
|
||||
|
||||
from kitty.terminfo import generate_terminfo # noqa
|
||||
def compile_terminfo(base):
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
proc = subprocess.run(['tic', '-x', '-o' + tdir, '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$'
|
||||
for error in proc.stderr.decode('utf-8').splitlines():
|
||||
if not re.match(regex, error):
|
||||
print(error, file=sys.stderr)
|
||||
tfiles = glob.glob(os.path.join(tdir, '*', 'xterm-kitty'))
|
||||
if not tfiles:
|
||||
raise SystemExit('tic failed to output the compiled kitty terminfo file')
|
||||
|
||||
with open('terminfo/kitty.terminfo', 'w') as f:
|
||||
f.write(generate_terminfo())
|
||||
tfile = tfiles[0]
|
||||
directory, xterm_kitty = os.path.split(tfile)
|
||||
_, directory = os.path.split(directory)
|
||||
odir = os.path.join(base, 'terminfo', directory)
|
||||
os.makedirs(odir, exist_ok=True)
|
||||
ofile = os.path.join(odir, xterm_kitty)
|
||||
shutil.move(tfile, ofile)
|
||||
|
||||
os.environ['TERMINFO'] = os.path.join(base, 'terminfo')
|
||||
subprocess.check_call(['tic', '-x', 'terminfo/kitty.terminfo'])
|
||||
|
||||
def generate_terminfo():
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(base)
|
||||
sys.path.insert(0, base)
|
||||
|
||||
from kitty.terminfo import generate_terminfo
|
||||
|
||||
with open('terminfo/kitty.terminfo', 'w') as f:
|
||||
f.write(generate_terminfo())
|
||||
|
||||
compile_terminfo(base)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate_terminfo()
|
||||
|
||||
10
setup.py
10
setup.py
@ -8,6 +8,7 @@ import importlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -635,16 +636,11 @@ def package(args, for_bundle=False, sh_launcher=False):
|
||||
if os.path.exists(libdir):
|
||||
shutil.rmtree(libdir)
|
||||
os.makedirs(os.path.join(libdir, 'logo'))
|
||||
build_terminfo = runpy.run_path('build-terminfo', run_name='import_build')
|
||||
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, 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$'
|
||||
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')
|
||||
build_terminfo['compile_terminfo'](odir)
|
||||
shutil.copy2('__main__.py', libdir)
|
||||
shutil.copy2('logo/kitty.rgba', os.path.join(libdir, 'logo'))
|
||||
shutil.copy2('logo/kitty.png', os.path.join(libdir, 'logo'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user