refactor: continue to refine standalone mode

This commit is contained in:
Daylin Morgan 2023-03-14 12:35:00 -05:00
parent 9c2581fafd
commit cb27f9a8d4
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F
3 changed files with 8 additions and 5 deletions

View file

@ -93,7 +93,6 @@ The only part necessary to modify if copied verbatim from below is the call to `
output of `viv freeze rich --standalone`: output of `viv freeze rich --standalone`:
```python ```python
# <<<<< auto-generated by daylinmorgan/viv (v.22.12a3) # <<<<< auto-generated by daylinmorgan/viv (v.22.12a3)
# fmt: off # fmt: off
def _viv_activate(*pkgs: str, track_exe: bool = False, name: str = "") -> None: # noqa def _viv_activate(*pkgs: str, track_exe: bool = False, name: str = "") -> None: # noqa
@ -102,7 +101,7 @@ def _viv_activate(*pkgs: str, track_exe: bool = False, name: str = "") -> None:
ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write # noqa ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write # noqa
(cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True) # noqa (cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True) # noqa
((sha256:=i("hashlib").sha256()).update((s(spec)+ # noqa ((sha256:=i("hashlib").sha256()).update((s(spec)+ # noqa
(((exe:=s(P(i("sys").executable).resolve()) if track_exe else "N/A")))).encode())) # noqa (((exe:=("N/A",s(P(i("sys").executable).resolve()))[e(track_exe)])))).encode())) # noqa
if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"): # noqa if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"): # noqa
v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {env.name}\n") # noqa v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {env.name}\n") # noqa
i("venv").EnvBuilder(with_pip=True,clear=True).create(env) # noqa i("venv").EnvBuilder(with_pip=True,clear=True).create(env) # noqa

View file

@ -1,4 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""
Example using the output of `viv freeze pyfiglet --standalone`.
With this function it's not necessary for
`viv` to exist anywhere on the system.
"""
# <<<<< auto-generated by daylinmorgan/viv (v.22.12a3) # <<<<< auto-generated by daylinmorgan/viv (v.22.12a3)
# fmt: off # fmt: off
@ -8,7 +13,7 @@ def _viv_activate(*pkgs: str, track_exe: bool = False, name: str = "") -> None:
ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write # noqa ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write # noqa
(cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True) # noqa (cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True) # noqa
((sha256:=i("hashlib").sha256()).update((s(spec)+ # noqa ((sha256:=i("hashlib").sha256()).update((s(spec)+ # noqa
(((exe:=s(P(i("sys").executable).resolve()) if track_exe else "N/A")))).encode())) # noqa (((exe:=("N/A",s(P(i("sys").executable).resolve()))[e(track_exe)])))).encode())) # noqa
if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"): # noqa if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"): # noqa
v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {env.name}\n") # noqa v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {env.name}\n") # noqa
i("venv").EnvBuilder(with_pip=True,clear=True).create(env) # noqa i("venv").EnvBuilder(with_pip=True,clear=True).create(env) # noqa
@ -24,7 +29,6 @@ _viv_activate("pyfiglet==0.8.post1")
# fmt: on # fmt: on
# >>>>> code golfed with <3 # >>>>> code golfed with <3
from pyfiglet import Figlet from pyfiglet import Figlet
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -492,7 +492,7 @@ def _viv_activate(*pkgs: str, track_exe: bool = False, name: str = "") -> None:
ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write ge,sys,P,ew=i("os").getenv,i("sys"),i("pathlib").Path,i("sys").stderr.write
(cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True) (cache:=(P(ge("XDG_CACHE_HOME",P.home()/".cache"))/"viv"/"venvs")).mkdir(parents=True,exist_ok=True)
((sha256:=i("hashlib").sha256()).update((s(spec)+ ((sha256:=i("hashlib").sha256()).update((s(spec)+
(((exe:=s(P(i("sys").executable).resolve()) if track_exe else "N/A")))).encode())) (((exe:=("N/A",s(P(i("sys").executable).resolve()))[e(track_exe)])))).encode()))
if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"): if (env:=cache/(name if name else (_id:=sha256.hexdigest()))) not in cache.glob("*/") or ge("VIV_FORCE"):
v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {{env.name}}\n") v=e(ge("VIV_VERBOSE"));ew(f"generating new vivenv -> {{env.name}}\n")
i("venv").EnvBuilder(with_pip=True,clear=True).create(env) i("venv").EnvBuilder(with_pip=True,clear=True).create(env)