Add a linux-package command to help linux packagers create good kitty packages

This commit is contained in:
Kovid Goyal 2017-01-08 12:17:44 +05:30
parent 34c947ba35
commit 50b0f44dff
3 changed files with 49 additions and 3 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
tags tags
build build
README.html README.html
linux-package

View File

@ -252,6 +252,27 @@ focus
launch emacs launch emacs
.... ....
== Note for linux packagers
While kitty does use python, it is not a traditional python package, so please do not install it in site-packages.
Instead run,
```
python3 setup.py linux-package
```
This will create the directory `linux-package` containing all the files need to run kitty. kitty can be run using
```
python3 linux-package
```
So simply create a launcher script named `kitty` that does that. You should
also create a second package named kitty-terminfo that installs the file
`linux-package/terminfo/x/xterm-kitty` into `/usr/share/terminfo` for whatever
location your distribution uses for terminfo files. Make the main kitty package
depend on `kitty-terminfo`. This allows users to install the terminfo file on
servers into which they ssh, without needing to install all of kitty.
== Resources on terminal behavior == Resources on terminal behavior
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

View File

@ -7,6 +7,7 @@ import re
import sys import sys
import sysconfig import sysconfig
import shlex import shlex
import shutil
import subprocess import subprocess
import argparse import argparse
@ -138,7 +139,7 @@ def compile_c_extension(module, *sources):
def option_parser(): def option_parser():
p = argparse.ArgumentParser() p = argparse.ArgumentParser()
p.add_argument('action', nargs='?', default='build', choices='build test'.split(), help='Action to perform (default is build)') p.add_argument('action', nargs='?', default='build', choices='build test linux-package'.split(), help='Action to perform (default is build)')
p.add_argument('--debug', default=False, action='store_true', p.add_argument('--debug', default=False, action='store_true',
help='Build extension modules with debugging symbols') help='Build extension modules with debugging symbols')
p.add_argument('--asan', default=False, action='store_true', p.add_argument('--asan', default=False, action='store_true',
@ -158,15 +159,38 @@ def find_c_files():
return tuple(ans) return tuple(ans)
def build(args):
init_env(args.debug, args.asan)
compile_c_extension('kitty/fast_data_types', *find_c_files())
def package(args):
ddir = 'linux-package'
if os.path.exists(ddir):
shutil.rmtree(ddir)
os.makedirs(ddir + '/terminfo/x')
shutil.copy2('__main__.py', ddir)
shutil.copy2('terminfo/x/xterm-kitty', ddir + '/terminfo/x')
def src_ignore(parent, entries):
return [x for x in entries if '.' in x and x.rpartition('.')[2] not in ('py', 'so', 'conf')]
shutil.copytree('kitty', ddir + '/kitty', ignore=src_ignore)
import compileall
compileall.compile_dir(ddir, optimize=2, quiet=1, workers=4)
def main(): def main():
if sys.version_info < (3, 5): if sys.version_info < (3, 5):
raise SystemExit('python >= 3.5 required') raise SystemExit('python >= 3.5 required')
args = option_parser().parse_args() args = option_parser().parse_args()
if args.action == 'build': if args.action == 'build':
init_env(args.debug, args.asan) build(args)
compile_c_extension('kitty/fast_data_types', *find_c_files())
elif args.action == 'test': elif args.action == 'test':
os.execlp(sys.executable, sys.executable, os.path.join(base, 'test.py')) os.execlp(sys.executable, sys.executable, os.path.join(base, 'test.py'))
elif args.action == 'linux-package':
build(args)
package(args)
if __name__ == '__main__': if __name__ == '__main__':