mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Make creating a linux package even easier
This commit is contained in:
@@ -261,22 +261,18 @@ Instead run,
|
|||||||
python3 setup.py linux-package
|
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
|
This will install kitty into the directory `linux-package`. You can run kitty
|
||||||
|
with `linux-package/bin/kitty`. All the files needed to run kitty will be in
|
||||||
|
`linux-package/lib/kitty`. The terminfo file will be installed into
|
||||||
|
`linux-package/share/terminfo`. Simply copy these files into `/usr` to install
|
||||||
|
kitty. In other words, `linux-package` is the staging area into which kitty is
|
||||||
|
installed. You can choose a different staging area, by passing the `--prefix`
|
||||||
|
argument to `setup.py`.
|
||||||
|
|
||||||
```
|
You should probably split kitty into two packages, `kitty-terminfo` that
|
||||||
python3 linux-package
|
installs the terminfo file and `kitty` that installs the main program.
|
||||||
```
|
This allows users to install the terminfo file on servers into which they ssh,
|
||||||
|
without needing to install all of kitty.
|
||||||
The `linux-package` directory can be renamed and moved anywhere on the
|
|
||||||
filesystem, it is self contained. So simply create a launcher script named
|
|
||||||
`/usr/bin/kitty` that calls `python3 /path/to/the/installed/linux-package/directory`.
|
|
||||||
|
|
||||||
You should also create a second package named kitty-terminfo that installs the
|
|
||||||
file `linux-package/terminfo/x/xterm-kitty` into `/usr/share/terminfo` (or
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
35
setup.py
35
setup.py
@@ -146,6 +146,7 @@ def option_parser():
|
|||||||
p.add_argument('--asan', default=False, action='store_true',
|
p.add_argument('--asan', default=False, action='store_true',
|
||||||
help='Turn on address sanitization to detect memory access errors. Note that if you do turn it on,'
|
help='Turn on address sanitization to detect memory access errors. Note that if you do turn it on,'
|
||||||
' you have to run kitty with the environment variable LD_PRELOAD=/usr/lib/libasan.so')
|
' you have to run kitty with the environment variable LD_PRELOAD=/usr/lib/libasan.so')
|
||||||
|
p.add_argument('--prefix', default='./linux-package', help='Where to create the linux package')
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
@@ -165,26 +166,46 @@ def build(args):
|
|||||||
compile_c_extension('kitty/fast_data_types', *find_c_files())
|
compile_c_extension('kitty/fast_data_types', *find_c_files())
|
||||||
|
|
||||||
|
|
||||||
|
def safe_makedirs(path):
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def package(args):
|
def package(args):
|
||||||
ddir = 'linux-package'
|
ddir = args.prefix
|
||||||
if os.path.exists(ddir):
|
libdir = os.path.join(ddir, 'lib', 'kitty')
|
||||||
shutil.rmtree(ddir)
|
terminfo_dir = os.path.join(ddir, 'share/terminfo/x')
|
||||||
os.makedirs(ddir + '/terminfo/x')
|
if os.path.exists(libdir):
|
||||||
shutil.copy2('__main__.py', ddir)
|
shutil.rmtree(libdir)
|
||||||
shutil.copy2('terminfo/x/xterm-kitty', ddir + '/terminfo/x')
|
os.makedirs(os.path.join(libdir, 'terminfo/x'))
|
||||||
|
safe_makedirs(terminfo_dir)
|
||||||
|
shutil.copy2('__main__.py', libdir)
|
||||||
|
shutil.copy2('terminfo/x/xterm-kitty', terminfo_dir)
|
||||||
|
shutil.copy2('terminfo/x/xterm-kitty', os.path.join(libdir, 'terminfo/x'))
|
||||||
|
|
||||||
def src_ignore(parent, entries):
|
def src_ignore(parent, entries):
|
||||||
return [x for x in entries if '.' in x and x.rpartition('.')[2] not in ('py', 'so', 'conf')]
|
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)
|
shutil.copytree('kitty', os.path.join(libdir, 'kitty'), ignore=src_ignore)
|
||||||
import compileall
|
import compileall
|
||||||
compileall.compile_dir(ddir, quiet=1, workers=4)
|
compileall.compile_dir(ddir, quiet=1, workers=4)
|
||||||
|
for root, dirs, files in os.walk(ddir):
|
||||||
|
for f in files:
|
||||||
|
path = os.path.join(root, f)
|
||||||
|
os.chmod(path, 0o755 if f.endswith('.so') else 0o644)
|
||||||
|
launcher_dir = os.path.join(ddir, 'bin')
|
||||||
|
safe_makedirs(launcher_dir)
|
||||||
|
run_tool([cc, '-ggdb', 'linux-launcher.c', '-o', os.path.join(launcher_dir, 'kitty')])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
args.prefix = os.path.abspath(args.prefix)
|
||||||
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
if args.action == 'build':
|
if args.action == 'build':
|
||||||
build(args)
|
build(args)
|
||||||
elif args.action == 'test':
|
elif args.action == 'test':
|
||||||
|
|||||||
Reference in New Issue
Block a user