mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-14 04:57:53 -06:00
docs: improve syspath example
This commit is contained in:
parent
57cd470bd4
commit
19c39ad471
1 changed files with 19 additions and 9 deletions
|
@ -2,20 +2,30 @@
|
||||||
"""
|
"""
|
||||||
Embed the viv.py on the sys.path at runtime rather than using PYTHONPATH
|
Embed the viv.py on the sys.path at runtime rather than using PYTHONPATH
|
||||||
"""
|
"""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
old_sys_path = sys.path.copy() # noqa
|
||||||
|
|
||||||
|
|
||||||
__import__("sys").path.append(
|
__import__("sys").path.append(
|
||||||
__import__("os").path.expanduser("~/.local/share/viv")
|
__import__("os").path.expanduser("~/.local/share/viv")
|
||||||
) # noqa # isort: off
|
) # noqa # isort: off
|
||||||
__import__("viv").use("pyfiglet", "setuptools") # noqa # isort: off
|
__import__("viv").use("rich") # noqa # isort: off
|
||||||
# pyfiglet requires pkg_resources which is part of setuptools
|
|
||||||
|
|
||||||
import sys
|
from difflib import unified_diff
|
||||||
|
|
||||||
from pyfiglet import Figlet
|
from rich import print
|
||||||
|
from rich.syntax import Syntax
|
||||||
|
|
||||||
f = Figlet(font="slant")
|
print("[bold italic yellow] Modified Sys.path")
|
||||||
print(f.renderText("Viv isn't venv!"))
|
print(
|
||||||
|
Syntax(
|
||||||
print("Sys path:")
|
"\n".join(
|
||||||
print("\n".join(sys.path))
|
unified_diff(
|
||||||
|
old_sys_path, sys.path, "pre-viv sys.path", "post-viv sys.path"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"diff",
|
||||||
|
theme="default",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue