Option for packagers to easily tune shell integration
This commit is contained in:
parent
afc5821809
commit
000e1012c6
@ -5,6 +5,7 @@ Build from source
|
|||||||
:alt: Build status
|
:alt: Build status
|
||||||
:target: https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI
|
:target: https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI
|
||||||
|
|
||||||
|
.. highlight:: sh
|
||||||
|
|
||||||
|kitty| is designed to run from source, for easy hack-ability. Make sure
|
|kitty| is designed to run from source, for easy hack-ability. Make sure
|
||||||
the following dependencies are installed first.
|
the following dependencies are installed first.
|
||||||
@ -105,7 +106,7 @@ make them available in the newly spawned shell.
|
|||||||
Then proceed with ``make`` or ``make app`` according to the platform specific instructions above.
|
Then proceed with ``make`` or ``make app`` according to the platform specific instructions above.
|
||||||
|
|
||||||
|
|
||||||
Note for Linux/macOS packagers
|
Notes for Linux/macOS packagers
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
The released |kitty| source code is available as a `tarball`_ from
|
The released |kitty| source code is available as a `tarball`_ from
|
||||||
@ -143,7 +144,27 @@ This applies to creating packages for |kitty| for macOS package managers such as
|
|||||||
brew or MacPorts as well.
|
brew or MacPorts as well.
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
Changing defaults for packages
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|kitty| has its defaults chosen to be suitable for a standalone distributable.
|
||||||
|
If you are packaging it a few of these might need to be changed.
|
||||||
|
|
||||||
|
update-checking
|
||||||
|kitty| has its own update check mechanism, if you would like to turn
|
|kitty| has its own update check mechanism, if you would like to turn
|
||||||
it off for your package, use
|
it off for your package, use::
|
||||||
``python3 setup.py linux-package --update-check-interval=0``
|
|
||||||
|
./setup.py linux-package --update-check-interval=0
|
||||||
|
|
||||||
|
shell-integration
|
||||||
|
|kitty| by default installs its :ref:`shell_integration` files into the user's
|
||||||
|
rc files. For a package, it might make more sense to distribute the shell
|
||||||
|
integration scripts into the system-wide shell vendor locations. The
|
||||||
|
shell integration files are found in the :file:`shell-integration`
|
||||||
|
directory. Copy them to the system wide shell vendor locations for each
|
||||||
|
shell, and use::
|
||||||
|
|
||||||
|
./setup.py linux-package --shell-integration=enabled\ no-rc
|
||||||
|
|
||||||
|
This will prevent kitty from modifying the user's shell rc files to load
|
||||||
|
the integration scripts.
|
||||||
|
|||||||
32
setup.py
32
setup.py
@ -70,7 +70,8 @@ class Options(argparse.Namespace):
|
|||||||
extra_logging: List[str] = []
|
extra_logging: List[str] = []
|
||||||
extra_include_dirs: List[str] = []
|
extra_include_dirs: List[str] = []
|
||||||
link_time_optimization: bool = 'KITTY_NO_LTO' not in os.environ
|
link_time_optimization: bool = 'KITTY_NO_LTO' not in os.environ
|
||||||
update_check_interval: float = 24
|
update_check_interval: float = 24.0
|
||||||
|
shell_integration: str = 'enabled'
|
||||||
egl_library: Optional[str] = os.getenv('KITTY_EGL_LIBRARY')
|
egl_library: Optional[str] = os.getenv('KITTY_EGL_LIBRARY')
|
||||||
startup_notification_library: Optional[str] = os.getenv('KITTY_STARTUP_NOTIFICATION_LIBRARY')
|
startup_notification_library: Optional[str] = os.getenv('KITTY_STARTUP_NOTIFICATION_LIBRARY')
|
||||||
canberra_library: Optional[str] = os.getenv('KITTY_CANBERRA_LIBRARY')
|
canberra_library: Optional[str] = os.getenv('KITTY_CANBERRA_LIBRARY')
|
||||||
@ -1113,13 +1114,23 @@ def package(args: Options, bundle_type: str) -> None:
|
|||||||
shutil.copytree('kittens', os.path.join(libdir, 'kittens'), ignore=src_ignore)
|
shutil.copytree('kittens', os.path.join(libdir, 'kittens'), ignore=src_ignore)
|
||||||
if for_freeze:
|
if for_freeze:
|
||||||
shutil.copytree('kitty_tests', os.path.join(libdir, 'kitty_tests'))
|
shutil.copytree('kitty_tests', os.path.join(libdir, 'kitty_tests'))
|
||||||
if args.update_check_interval != 24.0:
|
|
||||||
with open(os.path.join(libdir, 'kitty/options/types.py'), 'r+', encoding='utf-8') as f:
|
def repl(name: str, raw: str, defval: Union[str, float], val: Union[str, float]) -> str:
|
||||||
raw = f.read()
|
if defval == val:
|
||||||
nraw = raw.replace('update_check_interval: float = 24.0', f'update_check_interval: float = {args.update_check_interval!r}', 1)
|
return raw
|
||||||
|
prefix = f'{name}: {type(defval).__name__} ='
|
||||||
|
nraw = raw.replace(f'{prefix} {defval!r}', f'{prefix} {val!r}', 1)
|
||||||
if nraw == raw:
|
if nraw == raw:
|
||||||
raise SystemExit('Failed to change the value of update_check_interval')
|
raise SystemExit(f'Failed to change the value of {name}')
|
||||||
f.seek(0), f.truncate(), f.write(nraw)
|
return nraw
|
||||||
|
|
||||||
|
with open(os.path.join(libdir, 'kitty/options/types.py'), 'r+', encoding='utf-8') as f:
|
||||||
|
oraw = raw = f.read()
|
||||||
|
raw = repl('update_check_interval', raw, Options.update_check_interval, args.update_check_interval)
|
||||||
|
raw = repl('shell_integration', raw, Options.shell_integration, args.shell_integration)
|
||||||
|
if raw != oraw:
|
||||||
|
f.seek(0), f.truncate(), f.write(raw)
|
||||||
|
|
||||||
compile_python(libdir)
|
compile_python(libdir)
|
||||||
for root, dirs, files in os.walk(libdir):
|
for root, dirs, files in os.walk(libdir):
|
||||||
for f_ in files:
|
for f_ in files:
|
||||||
@ -1237,6 +1248,13 @@ def option_parser() -> argparse.ArgumentParser: # {{{
|
|||||||
help='When building a package, the default value for the update_check_interval setting will'
|
help='When building a package, the default value for the update_check_interval setting will'
|
||||||
' be set to this number. Use zero to disable update checking.'
|
' be set to this number. Use zero to disable update checking.'
|
||||||
)
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--shell-integration',
|
||||||
|
type=str,
|
||||||
|
default=Options.shell_integration,
|
||||||
|
help='When building a package, the default value for the shell_integration setting will'
|
||||||
|
' be set to this. Use "enabled no-rc" if you intend to install the shell integration scripts system wide.'
|
||||||
|
)
|
||||||
p.add_argument(
|
p.add_argument(
|
||||||
'--egl-library',
|
'--egl-library',
|
||||||
type=str,
|
type=str,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user