diff --git a/setup.py b/setup.py index 95060b1cc..23870ed0a 100755 --- a/setup.py +++ b/setup.py @@ -1538,9 +1538,7 @@ def main() -> None: args.prefix = os.path.abspath(args.prefix) os.chdir(base) if args.action == 'test': - os.execlp( - sys.executable, sys.executable, 'test.py' - ) + os.execlp('kitty', 'kitty', '+launch', 'test.py') if args.action == 'clean': clean() return diff --git a/test.py b/test.py index 889ce07f3..807da57ce 100755 --- a/test.py +++ b/test.py @@ -1,16 +1,13 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S kitty +launch # License: GPL v3 Copyright: 2016, Kovid Goyal import importlib import os -import sys import warnings from contextlib import contextmanager from tempfile import TemporaryDirectory from typing import Iterator -base = os.path.dirname(os.path.abspath(__file__)) - @contextmanager def env_vars(**kw: str) -> Iterator[None]: @@ -26,18 +23,12 @@ def env_vars(**kw: str) -> Iterator[None]: os.environ[k] = v -def init_env() -> None: - sys.path.insert(0, base) - - def main() -> None: warnings.simplefilter('error') current_home = os.path.expanduser('~') + os.sep paths = os.environ.get('PATH', '/usr/local/sbin:/usr/local/bin:/usr/bin').split(os.pathsep) path = os.pathsep.join(x for x in paths if not x.startswith(current_home)) launcher_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'kitty', 'launcher') - if not hasattr(sys, 'kitty_run_data'): - setattr(sys, 'kitty_run_data', {'bundle_exe_dir': launcher_dir, 'from_source': True}) path = f'{launcher_dir}{os.pathsep}{path}' with TemporaryDirectory() as tdir, env_vars( PYTHONWARNINGS='error', HOME=tdir, USERPROFILE=tdir, PATH=path, @@ -46,7 +37,6 @@ def main() -> None: XDG_DATA_DIRS=os.path.join(tdir, '.local', 'xdg'), XDG_CACHE_HOME=os.path.join(tdir, '.cache'), ): - init_env() m = importlib.import_module('kitty_tests.main') getattr(m, 'run_tests')()