viv/examples/sys_path.py

32 lines
677 B
Python
Raw Normal View History

2022-12-19 23:22:23 -06:00
#!/usr/bin/env python3
"""
Embed the viv.py on the sys.path at runtime rather than using PYTHONPATH
"""
2023-08-21 00:59:23 -05:00
import sys
old_sys_path = sys.path.copy() # noqa
2022-12-19 23:22:23 -06:00
__import__("sys").path.append(
__import__("os").path.expanduser("~/.local/share/viv")
2022-12-19 23:22:23 -06:00
) # noqa # isort: off
2023-08-21 00:59:23 -05:00
__import__("viv").use("rich") # noqa # isort: off
2022-12-19 23:22:23 -06:00
2023-08-21 00:59:23 -05:00
from difflib import unified_diff
2022-12-19 23:22:23 -06:00
2023-08-21 00:59:23 -05:00
from rich import print
from rich.syntax import Syntax
2022-12-19 23:22:23 -06:00
2023-08-21 00:59:23 -05:00
print("[bold italic yellow] Modified Sys.path")
print(
Syntax(
"\n".join(
unified_diff(
old_sys_path, sys.path, "pre-viv sys.path", "post-viv sys.path"
)
),
"diff",
theme="default",
)
)