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