diff --git a/.gitignore b/.gitignore index 39e841f35..95cd69349 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tags build README.html +linux-package diff --git a/README.asciidoc b/README.asciidoc index 32df0aba2..bd03b9fe1 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -252,6 +252,27 @@ focus 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 http://invisible-island.net/xterm/ctlseqs/ctlseqs.html diff --git a/setup.py b/setup.py index 90d86cf4f..9176c154c 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ import re import sys import sysconfig import shlex +import shutil import subprocess import argparse @@ -138,7 +139,7 @@ def compile_c_extension(module, *sources): def option_parser(): 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', help='Build extension modules with debugging symbols') p.add_argument('--asan', default=False, action='store_true', @@ -158,15 +159,38 @@ def find_c_files(): 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(): if sys.version_info < (3, 5): raise SystemExit('python >= 3.5 required') args = option_parser().parse_args() if args.action == 'build': - init_env(args.debug, args.asan) - compile_c_extension('kitty/fast_data_types', *find_c_files()) + build(args) elif args.action == 'test': os.execlp(sys.executable, sys.executable, os.path.join(base, 'test.py')) + elif args.action == 'linux-package': + build(args) + package(args) if __name__ == '__main__':