tooling(restepper): exit if pipx isnt installed

previously we'd install pipx and continue even though
we'd need ~/.local/bin under path which we cant do
without a shell restart anyways
This commit is contained in:
Mark Joshwel 2024-07-23 10:49:09 +08:00
parent e997d51663
commit 42e3ee1e8c

11
sync.py
View file

@ -183,25 +183,19 @@ def post_filter_repo_check(cp: CompletedProcess) -> CompletedProcess:
check_pipx_cp = run(["pipx", "--version"])
if check_pipx_cp.returncode == 0:
use_pipx = True
else:
run([executable, "-m", "pip", "install", "pipx"])
# double check
check_pipx_cp = run(["pipx", "--version"])
if check_pipx_cp.returncode == 0:
use_pipx = True
# if pipx still can't be found, might be some environment fuckery
# install git-filter-repo
pip_invocation: list[str] = ["pipx"] if use_pipx else [executable, "-m", "pip"]
print(
f"running '{' '.join([*pip_invocation, "install", "git-filter-repo"])}'... ",
end="",
flush=True,
)
install_rc = run([*pip_invocation, "install", "git-filter-repo"])
if install_rc.returncode != 0:
print("error")
_command_post_func(install_rc)
exit(install_rc.returncode)
else:
print("done\n")
@ -213,6 +207,7 @@ def post_filter_repo_check(cp: CompletedProcess) -> CompletedProcess:
"failure: could not install git-filter-repo automatically. "
"do it yourself o(*≧▽≦)ツ┏━┓"
)
exit(-1)
return cp